pneudralics Posted October 25, 2008 Share Posted October 25, 2008 Can't figure why php is only returning one row of data. //Website url $websiteurl = WEBSITEURL; //Retrieve gallery info $galleryselect = "SELECT * FROM gallery ORDER BY id ASC"; if ($galleryresult = mysql_query ($galleryselect)) { while ($row = mysql_fetch_array ($galleryresult)) { $gallery = $row['image']; } } ?> <table width="800" align="center"> <tr> <td width="100%" align="center"> <?php echo '<img src="'.$websiteurl.'/images/gallery/'.$gallery.'">'; ?> </td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/130046-solved-why-does-php-returning-only-one-row-of-data/ Share on other sites More sharing options...
wildteen88 Posted October 25, 2008 Share Posted October 25, 2008 Your HTML code needs to be within your while loop otherwise only the last result will be displayed. <table width="800" align="center"> <tr> <td width="100%" align="center"> <?php //Website url $websiteurl = WEBSITEURL; //Retrieve gallery info $galleryselect = "SELECT * FROM gallery ORDER BY id ASC"; if ($galleryresult = mysql_query ($galleryselect)) { while ($row = mysql_fetch_array ($galleryresult)) { $gallery = $row['image']; echo '<img src="'.$websiteurl.'/images/gallery/'.$gallery.'" />'; } } ?> </td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/130046-solved-why-does-php-returning-only-one-row-of-data/#findComment-674260 Share on other sites More sharing options...
pneudralics Posted October 25, 2008 Author Share Posted October 25, 2008 TG Your HTML code needs to be within your while loop otherwise only the last result will be displayed. <table width="800" align="center"> <tr> <td width="100%" align="center"> <?php //Website url $websiteurl = WEBSITEURL; //Retrieve gallery info $galleryselect = "SELECT * FROM gallery ORDER BY id ASC"; if ($galleryresult = mysql_query ($galleryselect)) { while ($row = mysql_fetch_array ($galleryresult)) { $gallery = $row['image']; echo '<img src="'.$websiteurl.'/images/gallery/'.$gallery.'" />'; } } ?> </td> </tr> </table> THanks. Quote Link to comment https://forums.phpfreaks.com/topic/130046-solved-why-does-php-returning-only-one-row-of-data/#findComment-674262 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.