<?php
$SearchNo = $_POST["SearchNo"];
$host= 'localhost';
$user= 'zutransportation';
$passwd= 'password';
$database= 'dbtransport';
$table= 'STUDENT';
$table2='BUS';

$connect= mysql_connect($host, $user, $passwd);
mysql_select_db($database);
$squery = "select * from $table where IDNo like '".$SearchNo."'";
$run= mysql_query($squery);
$num_results = mysql_num_rows($run);

if (!$SearchType )
{//1
echo "You have not selected search details. Please go back and try again. ";
}//1
else
{//2

if (!$connect)
{//3
echo"Error: Could not connect to database. Please try again later.";
}//3

else
{//4

echo "<div align=left>";
echo "";
echo "
<p>";
echo "<table border=1 width=97% >\n";
for ($i=0; $i<$num_results; $i++)
{//5
$row = mysql_fetch_array($run);

$SName = stripslashes($row["Name"]);
$IDNo = stripslashes($row["ID"]);
$email = stripslashes($row["Email"]);
$Phone = stripslashes($row["Phone"]);
$POBox = stripslashes($row["POBox"]);
$SDate = stripslashes($row["SDate"]);
$EDate = stripslashes($row["EDate"]);
$BusNo= stripslashes($row["busNum"]);
//$pquery= "select place from table2 where busNo='".$BusNo."'"; we'll added when everything is fine
}//5
echo "<tr>";
echo "<td width=21% height=2 valign=top><font color=#800000>&nbsp;nAME:</font></td>";
echo "<td width=64% height=2 valign=top colspan=3>&nbsp;".$SName."</td>";
echo "</tr>";

echo "<tr>";
echo "<td width=21% height=2 valign=top><font color=#800000>&nbsp;ID:</font></td>";
echo "<td width=64% height=2 valign=top colspan=3>&nbsp;".$IDNo."</td>";
echo "</tr>";
echo "<tr>";
echo "<td width=21% height=2 valign=top><font color=#800000>&nbsp;E-mail:</font></td>";
echo "<td width=64% height=2 valign=top colspan=3>&nbsp;".$email."</td>";
echo "</tr>";
echo "<tr>";
echo "<td width=21% height=2 valign=top><font color=#800000>&nbsp;Phone:</font></td>";
echo "<td width=64% height=2 valign=top colspan=3>&nbsp;".$Phone."</td>";
echo "</tr>";
echo "<tr>";
echo "<td width=21% height=2 valign=top><font color=#800000>&nbsp;P.O.Box:</font></td>";
echo "<td width=64% height=2 valign=top colspan=3>&nbsp;".$POBox."</td>";
echo "</tr>";
echo "<tr>";
echo "<td width=21% height=2 valign=top><font color=#800000>&nbsp;Starting Date:</font></td>";
echo "<td width=64% height=2 valign=top colspan=3>&nbsp;".$SDate."</td>";
echo "</tr>";
echo "<tr>";
echo "<td width=21% height=2 valign=top><font color=#800000>&nbsp;Ending Date:</font></td>";
echo "<td width=64% height=2 valign=top colspan=3>&nbsp;".$EDate."</td>";
echo "</tr>";
echo "<tr>";
echo "<td width=21% height=2 valign=top><font color=#800000>&nbsp;Bus Number:</font></td>";
echo "<td width=64% height=2 valign=top colspan=3>&nbsp;".$BusNo."</td>";
echo "</tr>";
/* This one when everything goes fine 
echo "<tr>";
echo "<td width=21% height=2 valign=top><font color=#800000>&nbsp;Place:</font></td>";
echo "<td width=64% height=2 valign=top colspan=3>&nbsp;".$pquery."</td>";
echo "</tr>";
*/
echo "</table>\n";

}//4
}//2



?>

Please help help :sad:

I don't know why I get this result always

"You have not selected search details. Please go back and try again. "

please help meeeeee

Edited 3 Years Ago by Dani: Formatting fixed

if (!$SearchType )
{//1
echo "You have not selected search details. Please go back and try again. ";
}//1

Replace $SearchType with $SearchNo - should work fine

This article has been dead for over six months. Start a new discussion instead.