Jump to content

Infinite Loop - Oops


ccpokerd
 Share

Recommended Posts

Hey guys,I'm trying to create a loop to display menu items for each entry in a database...

$qry = "SELECT * FROM pages";$result = mysql_query($qry);$num = mysql_num_rows($result);$i = 0;while($i < $num) {	$dbPageID = mysql_result($result, $i, "id");	$dbPageTitle = mysql_result($result, $i, "title");echo "<a href=\"edit.php?id=$dbPageID\">$dbPageTitle</a><br />";}

at the moment I have just the one entry for testing purposes, and basically it just displays an infinite amount of links to edit this one entry. help!

Link to comment
Share on other sites

Try this:

$qry = "SELECT * FROM pages";$result = mysql_query($qry);while($row = mysql_fetch_array($result)){	$dbPageID = $row['id'];	$dbPageTitle = $row['title'];echo "<a href='edit.php?id=$dbPageID'>$dbPageTitle</a><br />";}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...