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

 

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.