Page 1 of 1

insert MySQL data as image into html

Posted: Fri Jul 13, 2007 4:46 pm
by mr yes
I want to make a page which uses all the data from a MySQL field to create a gallery of images.

all of the entries in the field are the same dimensions and are in the form of filename.gif

when a new entry is added to the database i want a another image to appear

Code: Select all

<?php

$result = mysql_query("SELECT * FROM thumbnails ORDER BY id");

while($row = mysql_fetch_array($result))
  {
  echo $row['gif'];
  echo "<br />";
  }

mysql_close($con);
?>
this code pretty much does what i need but i dont have a clue where to put the img tags.

Any ideas?

Posted: Fri Jul 13, 2007 4:55 pm
by ankhmor
Ok. So the thing is if $row['gif'] is the name of the file then go with this:

instead of echo

Code: Select all

$row['gif']
write

Code: Select all

echo "<img scr='".$row['gif']."' scr='".$row['gif']."'>";
sorry but im in a hurry so threre might be some mistakes in the code (like I might have forgotten to put ' or something);

CQ;