Pittlimey Posted April 24, 2006 Share Posted April 24, 2006 I have checked the mysql query... using mysqladmin, it works fine... I can create and put data into the database no problem... but this retrieval query is driving me nuts...I am trying to retrieve one row, and one only from the database, comparing data from a specific column.it should be easy... but I cannot figure out what I am doing wrong...any help would be greatly appreciated...<code><?PHP $cfgProgDir = 'mypages/'; include($cfgProgDir . "secure.php");?><html> <head> <title></title> </head> <body><form name="ice" action="testing.php" method="post"><input type="button" value="N Number" onClick="submit" id="getinfo" /><input type="text" name="n_number" size= "8" maxlength="8"value="" id="n_number" name="n_number" /> </body></html><?if (isset($_POST['getinfo'])) {$Ron=$_POST['ron'];$N_Number=$_POST['n_number'];$FleetType=$_POST['fleettype'];$FlightNumber=$_POST['flightnumber'];$query = "SELECT FleetType, FlightNumber, Ron, FROM `AircraftInfo` WHERE `N_Number` = '$n_number'" ;$result = mysql_query($query);echo "<b><center>Database Output</center></b><br><br>";$Ron=mysql_result($result,$i,'ron');$N_Number==mysql_result($result,$i,'n_number');$FleetType==mysql_result($result,$i,'fleettype');$FlightNumber==mysql_result($result,$i,'flightnumber');echo "<b>Fleet Type: $fleettype</b><br>Flight Number: $flightnumber</b><br><b>Ron: $ron</b><br><b>N Number: $n_number</b><br><br><hr><br>";}?></code> Quote Link to comment https://forums.phpfreaks.com/topic/8288-solved-retrieving-data-from-mysql-dbase-query/ Share on other sites More sharing options...
Barand Posted April 24, 2006 Share Posted April 24, 2006 [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]if (isset($_POST['getinfo'])) [/quote]You don't have a form element whose name is 'getinfo' so the code never executes.Similarly, you don't POST anything named 'ron', 'fleettype' or 'flightnumber', so you may as well remove[code]$Ron=$_POST['ron'];$FleetType=$_POST['fleettype'];$FlightNumber=$_POST['flightnumber'];[/code]Change button code to[code]<input type="submit" value="N Number" name="getinfo" />[/code] Quote Link to comment https://forums.phpfreaks.com/topic/8288-solved-retrieving-data-from-mysql-dbase-query/#findComment-30229 Share on other sites More sharing options...
Pittlimey Posted April 25, 2006 Author Share Posted April 25, 2006 [!--quoteo(post=368110:date=Apr 24 2006, 03:34 PM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Apr 24 2006, 03:34 PM) [snapback]368110[/snapback][/div][div class=\'quotemain\'][!--quotec--]You don't have a form element whose name is 'getinfo' so the code never executes.Similarly, you don't POST anything named 'ron', 'fleettype' or 'flightnumber', so you may as well remove[code]$Ron=$_POST['ron'];$FleetType=$_POST['fleettype'];$FlightNumber=$_POST['flightnumber'];[/code]Change button code to[code]<input type="submit" value="N Number" name="getinfo" />[/code][/quote]Barand, thanks for the help, here is a working version just in case anyone else can benefit.[code]<?PHP $cfgProgDir = 'phpSecurePages/'; include($cfgProgDir . "secure.php"); ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN"><html> <head> <title></title> </head> <body><form name="ice" action="testing.php" method="post"><input type="submit" value="N Number" name="getinfo" /><input type="text" name="n_number" size= "8" maxlength="8"value="" id="n_number" name="n_number" /> </body></html><?if (isset($_POST["getinfo"])) {$N_Number=$_POST['n_number'];$sql = "SELECT `FlightNumber`,`FleetType`,`Ron` FROM `AircraftInfo` WHERE `N_Number` = '$n_number' LIMIT 0, 30 ";$result = mysql_query($sql);while($extract = mysql_fetch_array($result)){ $fleettype = $extract['FleetType']; $flightnumber = $extract['FlightNumber']; $Ron = $extract['Ron']; $N_Number = $extract['N_Number'];}echo "<b><center>".$fleettype.$flightnumber.$Ron.$n_number."</center></b><br><br>";echo "<b><center>Database Output</center></b><br><br>";$Ron=mysql_result($result,$i,'Ron');$N_Number=mysql_result($result,$i,'N_Number');$FleetType=mysql_result($result,$i,'FleetType');$FlightNumber=mysql_result($result,$i,'FlightNumber');echo "<b>Fleet Type: $FleetType</b><br><b>Flight Number: $FlightNumber</b><br><b>Ron: $Ron</b><br><b>N Number: $N_Number</b><br><br><hr><br>";}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/8288-solved-retrieving-data-from-mysql-dbase-query/#findComment-30531 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.