Jump to content

NEED HELP: While loop is skipping records, why?


hellrising

Recommended Posts

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

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.

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.

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 . "/>";

}

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 . "'/>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.