me1000 Posted May 16, 2008 Share Posted May 16, 2008 So basically my while loops will never stop... on top of that it looks like my query (only when ran from the browser via this script) will only return one entry. here is the loop $query="SELECT * FROM nav ORDER BY 'ORDER' ASC"; //echo $query; while ($row = mysql_fetch_array(mysql_query($query))) { echo '<div class="navBullet"><a href="http://google.com">'.$row['ASSO'].'</a></div>'; } im sure it is just something stupid that im doing, but I cant seem to find it. I know the query is good, because I have ran it through my sql manager, and it returned the correct entries. Link to comment https://forums.phpfreaks.com/topic/105867-solved-infinite-while-loop/ Share on other sites More sharing options...
perezf Posted May 16, 2008 Share Posted May 16, 2008 try this $query="SELECT * FROM nav ORDER BY 'ORDER' ASC"; $runquery = mysql_query($query); //echo $query; while ($row = mysql_fetch_array(mysql_query($runquery))) { echo '<div class="navBullet"><a href="http://google.com">'.$row['ASSO'].'</a></div>'; } Link to comment https://forums.phpfreaks.com/topic/105867-solved-infinite-while-loop/#findComment-542562 Share on other sites More sharing options...
me1000 Posted May 16, 2008 Author Share Posted May 16, 2008 That was it, Just curious: why I couldnt run the mysql_query() function inside of the _fetch_array() function? Thank you Link to comment https://forums.phpfreaks.com/topic/105867-solved-infinite-while-loop/#findComment-542565 Share on other sites More sharing options...
Fadion Posted May 16, 2008 Share Posted May 16, 2008 Dont know if thats the problem, but u dont need single quotes on ORDER: $query="SELECT * FROM nav ORDER BY order ASC"; A good way to write your code should be: $query="SELECT * FROM nav ORDER BY 'ORDER' ASC"; $results = mysql_query($query) or die(mysql_error()); //this will show an error if the query isnt correct while ($row = mysql_fetch_array($results)) { echo '<div class="navBullet"><a href="http://google.com">'.$row['ASSO'].'</a></div>'; } Link to comment https://forums.phpfreaks.com/topic/105867-solved-infinite-while-loop/#findComment-542567 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.