Can anybody check my basic code below and tell me plz,plzzz, why my output only gives me the last row of the table?
It works, but the while ($row = mysql_fetch_array($get_image_res)) only gives me one line. I am using Ubuntu6.10 VMware Server in windows XP. I tried to replaced the "while" loop for a "For" loop and still the same. now if I put the query statement directly in MySQL it gives me all the rows of the table.
<?php
// Start retreiving from database
$display_block = "<h1>Here are your Pictures</h1>";
$get_image = "SELECT id, img_id, pic_name, pic_desc, pic_image FROM IMG_TABLE";
$get_image_res = mysql_query($get_image) or die(mysql_error($connection));
if($get_image_res)
{ $msg = "I am in table";}
if(mysql_num_rows($get_image_res) < 1)
{//invalid image
$display_block .= "<p><em>Invalid Picture Selection</em></p>";
}
else
{//valid item
while ($row = mysql_fetch_array($get_image_res))
{
$img_id = $row['img_id'];
$pic_name = stripslashes($row['pic_name']);
$pic_desc = stripslashes($row['pic_desc']);
$pic_image = $row['pic_image'];
}
}
//make breadcrumb trail
$display_block .= "<p>your are viewing the pictures <BR/><BR/> | $img_id | $pic_name | $pic_desc | <a href =\"images/$pic_image\" target=\"_blank\">$pic_image</a></p>";
//free result
mysql_free_result($get_image_res);
mysql_close($connection);
?>