Jump to content

[SOLVED] infinite (while) loop


me1000

Recommended Posts

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

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>';
}	

 

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>';
}	

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.