Jump to content


SQL results in table help me please:)

  • Please log in to reply
No replies to this topic

#1 peoplespaul

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 05 April 2006 - 08:45 PM


The first question is that i have is how to make one large form which retrieves data from a database and outputs it into a table.

the current code i have is outputting it to a table but not correctly:? eg if there are four results to the query only 3 will be outputted :S and the 1st line in therewill be each row's title's, it is most likey something simple. would be grateful for the help.

below is the code for the form in search.php

<FORM METHOD= "post" ACTION= "dest_loc.php">

Departure location

<!-- text box with attributes set -->
<INPUT NAME ="dep_loc" TYPE="text" SIZE=40 MAXLENGTH=40>
Destination location

<INPUT NAME ="arr_loc" TYPE="text" SIZE=20 MAXLENGTH=40>

<input type="submit" value="Search"></H4>


here is the php in dept_loc that i have done

if (!$server):
print ("error connecting to server");


$dep_loc = $HTTP_POST_VARS['dep_loc'];
$arr_loc = $HTTP_POST_VARS['arr_loc'];
$sql="SELECT * FROM `airline`";

$sql = $sql." WHERE ffrom = '$dep_loc'";

$sql = $sql." AND fto = '$arr_loc'";

echo $sql."<br><br>";

if (mysql_error()):
print ("there has been an error<BR>".mysql_error());
print "There have been ".mysql_num_rows($result)." records returned<BR>";

while ($row=mysql_fetch_array($result))

echo '<table border="1">

while (list ($ffrom, $fto, $flight_no, $departure, $arrival) = mysql_fetch_row($result)) {
echo "<TR><TD>$ffrom</TD>
echo '</table>';



i would be grateful as telling me why its not working correctly to save me makin the same mistake in the future

the second question i have is my php doesnt seem to validate any idea's??

thanks for your help

Paul (peoplespaul@hotmail.com)

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users