Page 1 of 1

problem with while list loop

Posted: Mon May 01, 2006 5:02 am
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