brownshoe Posted October 13, 2008 Share Posted October 13, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/128138-solved-i-think-my-query-creates-an-infinite-loop-dont-know-why/ Share on other sites More sharing options...
corbin Posted October 13, 2008 Share Posted October 13, 2008 Find a php+mysql tutorial. You're going about it entirely wrong. Quote Link to comment https://forums.phpfreaks.com/topic/128138-solved-i-think-my-query-creates-an-infinite-loop-dont-know-why/#findComment-663659 Share on other sites More sharing options...
Zane Posted October 13, 2008 Share Posted October 13, 2008 $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)) { Quote Link to comment https://forums.phpfreaks.com/topic/128138-solved-i-think-my-query-creates-an-infinite-loop-dont-know-why/#findComment-663779 Share on other sites More sharing options...
brownshoe Posted October 13, 2008 Author Share Posted October 13, 2008 Thanks, Zanus. That did the trick! Quote Link to comment https://forums.phpfreaks.com/topic/128138-solved-i-think-my-query-creates-an-infinite-loop-dont-know-why/#findComment-663881 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.