twilitegxa Posted February 18, 2011 Share Posted February 18, 2011 Now I am trying to display the images from my table and I have almost got it working, except for one small thing --- it seems to be displaying all the records, but instead of displaying the right image for each record, it's displaying the same image across all the records. Can anyone tell me what I have done wrong? this is the gallery <?php $dbhost = 'localhost'; $dbuser = 'webdes17_lizkula'; $dbpass = 'minimoon'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'webdes17_jewelry'; mysql_select_db($dbname); $all_records = "SELECT * FROM gallery"; $all_records_res = mysql_query($all_records); $image = mysql_result($all_records_res, 0, 'image'); while($nt=mysql_fetch_array($all_records_res)){ echo "<img src=http://www.webdesignsbyliz.com/wdbl_wordpress/wp-content/themes/twentyten_2/upload/$image>"; } ?> I'm guessing I have the $image variable in the wrong place, but when I tried placing it within the while statement, the page never loaded, and instead acted like it was loading forever. What am I doing wrong? Here is the link to the page so you can see what is happening: http://webdesignsbyliz.com/wdbl_wordpress/test-submit/ Link to comment https://forums.phpfreaks.com/topic/228133-displaying-image-from-table/ Share on other sites More sharing options...
BlueSkyIS Posted February 18, 2011 Share Posted February 18, 2011 you only set $image once. it's not going to change unless you set it to something else. Link to comment https://forums.phpfreaks.com/topic/228133-displaying-image-from-table/#findComment-1176453 Share on other sites More sharing options...
eutu9 Posted February 18, 2011 Share Posted February 18, 2011 Try this: while($nt=mysql_fetch_array($all_records_res)){ echo "<img src=http://www.webdesignsbyliz.com/wdbl_wordpress/wp-content/themes/twentyten_2/upload/".$nt['image'].">"; } Link to comment https://forums.phpfreaks.com/topic/228133-displaying-image-from-table/#findComment-1176457 Share on other sites More sharing options...
twilitegxa Posted February 18, 2011 Author Share Posted February 18, 2011 Perfect! Thank you soooo much!!!! Link to comment https://forums.phpfreaks.com/topic/228133-displaying-image-from-table/#findComment-1176458 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.