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

$auth_aircraft_info= mysql_fetch_array($auth_aircraft); //
echo "

</pre>
<table align='\"center\"'>

Type
Registration
Location


";

While ($auth_aircraft_info) { //</

 

like so

while ($auth_aircraft_info= mysql_fetch_array($auth_aircraft)) {

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.