Jump to content

[SOLVED] I think my query creates an infinite loop, don't know why...


brownshoe

Recommended Posts

Hi,

 

I wrote a query which, in my web host's DBMS command line interface (PHP My Admin) gets me the results I want.  However, when I put it into a script on a page, I'm getting the first line of the desired result repeated over and over and over again until I hit "stop" on my browser.  I don't get it... here's the code:

 

$user='1';
$pilot_location='W19';

$auth_aircraft_query="SELECT `aircraft`.`AircraftID`, `aircraft`.`registration`, `aircraft`.`location`, 

`aircraft`.`equipment_code`, `authorized_pilots`.`PilotID` FROM `aircraft`, `authorized_pilots` WHERE 

(`aircraft`.`location`='$pilot_location' AND `authorized_pilots`.`PilotID`='$user' AND 

`authorized_pilots`.`AircraftID`=`aircraft`.`AircraftID`)";

$auth_aircraft= mysql_query($auth_aircraft_query);

$auth_aircraft_info= mysql_fetch_array($auth_aircraft);

echo "

<table align=\"center\">
<TR>
<td>Type</td>
<td>Registration</td>
<td>Location</td>
</tr>

";

While ($auth_aircraft_info) {

$code=$auth_aircraft_info[equipment_code];
$registration=$auth_aircraft_info[registration];
$location=$auth_aircraft_info[location];

echo "<tr>
	<td>$code</td>
	<td>$registration</td>
	<td>$location</td>
</tr>

";
}

echo "</table>";

 

Am I doing something wrong with the while loop?  I've done stuff like this before and never had this problem.

 

If anybody can spot the problem, I'd really appreciate it!

 

Thanks,

 

Dave

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.