hellrising Posted April 5, 2010 Share Posted April 5, 2010 I may of been looking at this for to long, but I have got 10 records in a database, all with the same album id. BUT it will only display 5 of them.... Why! $gal = mysql_query("SELECT * FROM albums WHERE profilename = '$DisplayProfile'"); while($albums = mysql_fetch_assoc($gal)){ //generate information for albums $albumid = $albums["ID"]; //ID $albumname = $albums["albumname"]; //name $albumshot = $profile["profilename"]; //profilename $galimage = mysql_query("SELECT * FROM content WHERE albumid = ".$albumid." AND AdminAuth = 'true'"); //display generated information for albums echo "<h3>".$albumname."</h3>"; while($albumphotos = mysql_fetch_assoc($galimage)){ $albumimage = $albumphotos["contenturl"]; //content location echo "<img src='content/" . $albumshot . "/" . $albumimage . "/>"; } } Looking at the MySQL database it looks like it is skipping alternate records...I am baffled..... Please help Quote Link to comment https://forums.phpfreaks.com/topic/197685-need-help-while-loop-is-skipping-records-why/ Share on other sites More sharing options...
TeddyKiller Posted April 5, 2010 Share Posted April 5, 2010 I'm confused as to why you have a second while? <?php $gal = mysql_query("SELECT * FROM albums WHERE profilename = '$DisplayProfile'"); while($albums = mysql_fetch_assoc($gal)){ //generate information for albums $albumid = $albums["ID"]; //ID $albumname = $albums["albumname"]; //name $albumshot = $profile["profilename"]; //profilename $galimage = mysql_query("SELECT * FROM content WHERE albumid = ".$albumid." AND AdminAuth = 'true'"); //display generated information for albums echo "<h3>".$albumname."</h3>"; $albumphotos = mysql_fetch_assoc($galimage); $albumimage = $albumphotos["contenturl"]; //content location echo "<img src='content/" . $albumshot . "/" . $albumimage . "/>"; } ?> Like I say, you don't need it.. so you might aswell stick with that. Quote Link to comment https://forums.phpfreaks.com/topic/197685-need-help-while-loop-is-skipping-records-why/#findComment-1037474 Share on other sites More sharing options...
hellrising Posted April 6, 2010 Author Share Posted April 6, 2010 The first while... while($albums = mysql_fetch_assoc($gal)){ lists and loops all albums, and the second while... while($albumphotos = mysql_fetch_assoc($galimage)){ lists all the photos in the album. But i tryed just listing all the photos and removed the albums, but it would still only display 5 out of 10 photos skipping alternate records. Quote Link to comment https://forums.phpfreaks.com/topic/197685-need-help-while-loop-is-skipping-records-why/#findComment-1037491 Share on other sites More sharing options...
Pikachu2000 Posted April 6, 2010 Share Posted April 6, 2010 I'd start by echoing the query, then pasting it in to phpMyAdmin, or the mysql> client to see exactly what it returns, then debug from there. Quote Link to comment https://forums.phpfreaks.com/topic/197685-need-help-while-loop-is-skipping-records-why/#findComment-1037493 Share on other sites More sharing options...
hellrising Posted April 6, 2010 Author Share Posted April 6, 2010 it so strange because i have other query's on the page that are displaying all the records its just this query that is doing it... but ill try and post the result! Quote Link to comment https://forums.phpfreaks.com/topic/197685-need-help-while-loop-is-skipping-records-why/#findComment-1037497 Share on other sites More sharing options...
hellrising Posted April 6, 2010 Author Share Posted April 6, 2010 it displays all 10 records... SELECT * FROM Content WHERE albumid =7 AND AdminAuth = 'true' this is correct so the problem is not in the query... Quote Link to comment https://forums.phpfreaks.com/topic/197685-need-help-while-loop-is-skipping-records-why/#findComment-1037499 Share on other sites More sharing options...
TeddyKiller Posted April 6, 2010 Share Posted April 6, 2010 Does something like this work? $galimage = mysql_query("SELECT * FROM content WHERE albumid = 7 AND AdminAuth = 'true'"); while($image = mysql_fetch_array($galimage)){ echo $image['imagecollumname']; } Quote Link to comment https://forums.phpfreaks.com/topic/197685-need-help-while-loop-is-skipping-records-why/#findComment-1037500 Share on other sites More sharing options...
hellrising Posted April 6, 2010 Author Share Posted April 6, 2010 Stunned.... while($albumphotos = mysql_fetch_assoc($galimage)){ $albumimage = $albumphotos["contenturl"]; //content location echo $albumimage; } worked, it displays all records but why not. while($albumphotos = mysql_fetch_assoc($galimage)){ $albumimage = $albumphotos["contenturl"]; //content location echo "<img src='content/" . $albumshot . "/" . $albumimage . "/>"; } Quote Link to comment https://forums.phpfreaks.com/topic/197685-need-help-while-loop-is-skipping-records-why/#findComment-1037507 Share on other sites More sharing options...
hellrising Posted April 6, 2010 Author Share Posted April 6, 2010 i knew id been looking at it to long and totally missed a single ' while($albumphotos = mysql_fetch_assoc($galimage)){ $albumimage = $albumphotos["contenturl"]; //content location echo "<img src='content/" . $albumshot . "/" . $albumimage . "/>"; } <img src='content/" . $albumshot . "/" . $albumimage . "'/> Quote Link to comment https://forums.phpfreaks.com/topic/197685-need-help-while-loop-is-skipping-records-why/#findComment-1037510 Share on other sites More sharing options...
TeddyKiller Posted April 6, 2010 Share Posted April 6, 2010 The question is.. why would a simple ' display every other image? Quote Link to comment https://forums.phpfreaks.com/topic/197685-need-help-while-loop-is-skipping-records-why/#findComment-1037511 Share on other sites More sharing options...
hellrising Posted April 6, 2010 Author Share Posted April 6, 2010 i supose because its not closing the src... I have no idea...lol Quote Link to comment https://forums.phpfreaks.com/topic/197685-need-help-while-loop-is-skipping-records-why/#findComment-1037515 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.