problem with while list loop

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
peaforabrain
Forum Newbie
Posts: 7
Joined: Mon May 01, 2006 4:49 am

problem with while list loop

Post by peaforabrain »

Hi,

I have been stuck with a function to display countries in a loop. The idea is that the information is extracted from two different fields in the db. One field just lists the countries and the other is the field that has information attached to it. So when the while loop scans through and compares the two, it puts a number next to the country that has listings within.

This works up to a point, but only lists the numbers next to the last field it finds with listings and skips the previous countries.

To be more specific: I need to break out of the while loop.

This is the code anyway, can anyone help.

Code: Select all

if ($contC == $list_item)
		{													
			$a=getArrayOfAllValuesB("continent");				
			while(list(,$OneContinent)=each($a))
			{				
				$contC=$OneContinent['name'];
				$num=$OneContinent['num'];
			}						   					   						
			
			echo "<a href=\"agent_country.php?continent=$list_item\">$list_item ($num)</a><br>";
		}
		else
		{
			echo " <a href=\"agent_country.php?continent=$list_item\">$list_item</a><br>";
		}			
}
//HawleyJR: Made the code readible
Thanks
Post Reply