php/mysql how to select a image based on its id?

  • Thread starter Thread starter Rach
  • Start date Start date
R

Rach

Guest
Hey Everyone,

What i am trying to do is display a image based on its id in the mysql. In the mysql i have the url to where the image is located and then each image has an id associated (1,2,3 etc). The problem i am having is it displays the same picture for all 6 pictures i want to display instead of 6 different pictures. So my question is how can i select the id for each picture so it will go something like picture 1, picture 2, picture 3 etc? Here is what i currently have

$result = mysql_query("SELECT * FROM
categorypics order by id");
while($row = mysql_fetch_array($result))
{




$products_image = $row["products_image"]; //picname is the name of the field in the images table
}

echo "<img src = '$products_image'>";

If anyone could show a example or a link on how to do this i would appreciate it.

Thank you,
Rach
hey colanth,
actually i had gotten that line from another website and forgot to change picname to what i have which is products_image.
 
Back
Top