Eggzorcist Posted August 19, 2010 Share Posted August 19, 2010 I'm having trouble with listing a query with while loops... What am I doing wrong? $user = $database->escape_value($_SESSION['username']); while($row = mysql_fetch_assoc($database->query("SELECT * FROM project WHERE user = '{$user}'"))){ echo $row['name']; } THank you Link to comment https://forums.phpfreaks.com/topic/211196-while-query/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 19, 2010 Share Posted August 19, 2010 You are re-executing the query in a forever-loop because you put the code that executes the query inside of the while() condition. You would need to execute the query once, before the start of the while(){} loop, not inside of the while() condition. The while(){} loop should only iterate over the result set that the query returns. Link to comment https://forums.phpfreaks.com/topic/211196-while-query/#findComment-1101300 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.