ccpokerd Posted June 7, 2010 Share Posted June 7, 2010 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 More sharing options...
End User Posted June 7, 2010 Share Posted June 7, 2010 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 More sharing options...
ccpokerd Posted June 7, 2010 Author Share Posted June 7, 2010 ohhhi forgot$i++hahahasilly me Link to comment Share on other sites More sharing options...
ccpokerd Posted June 7, 2010 Author Share Posted June 7, 2010 your way seems much more efficient anywaythanks Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.