insert MySQL data as image into html

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mr yes
Forum Newbie
Posts: 3
Joined: Thu Jul 12, 2007 5:19 pm

insert MySQL data as image into html

Post 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?
ankhmor
Forum Newbie
Posts: 12
Joined: Fri Jul 13, 2007 4:45 pm

Post 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;
Post Reply