SEARCH MULTIPLE TABLE IN HTML

Please dont live any blank space while searching
Search Reservation Number
**this part is the searching
searchresult.php**
$table=$_POST['table'];
$search=$_POST['search'];
if ($search == "" or $table=="")
{
echo" back ";
echo "You forgot to enter the reservation number";
exit;
}
$dbhost = 'localhost';
$dbuser = 'europcar_msic';
$dbpass = 'msictran';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'europcar_msic';
mysql_select_db($dbname);
if ($table=="cd")
{
$sql = mysql_query("select * from cd where Rnum like '$search'");
}
if ($table=="sd")
{
$sql = mysql_query("select * from sd where Rnum like '$search'");
}
if ($table=="ch")
{
$sql = mysql_query("select * from ch where Rnum like '$search'");
}
if ($table=="pudo")
{
$sql = mysql_query("select * from pudo where Rnum like '$search'");
}
if ($table=="sdti")
{
$sql = mysql_query("select * from sdtexas where Rnum like '$search'");
}
if ($table=="chti")
{
$sql = mysql_query("select * from chtexas where Rnum like '$search'");
}
if ($table=="cdti")
{
$sql = mysql_query("select * from cdtexas where Rnum like '$search'");
}
if ($table=="pudoti")
{
$sql = mysql_query("select * from pudotexas where Rnum like '$search'");
}
while ($row=mysql_fetch_array($sql))
{
echo " ";
echo " ";
echo " Reservation Number
"; echo "Name
"; echo "Vehicle Type
"; echo "Origin
"; echo "Pick up date
"; echo "Time
"; echo "Destination
"; echo "Return Date
"; echo " Return Time
"; echo " Contact Number
"; echo " Address
"; echo "
"; echo" ";
echo" back ";
echo" ";
echo " $row[Rnum]";
echo "$row[Fname] $row[Lname]";
echo "$row[Vehicle]";
echo "$row[Origin]";
echo "$row[Pickday] $row[Pickmonth] ";
echo "$row[Pickhour] : $row[Pickmin]";
echo "$row[Destination]";
echo "$row[Rday] $row[Rmonth] ";
echo "$row[Rhour] : $row[Rmin]";
echo "$row[Contact]";
echo "$row[Zip],$row[Address],$row[City] $row[Country]";
echo '
';
}
//This counts the number or results - and if there wasn't any it gives them a little message explaining that
$anymatches=mysql_num_rows($sql);
if ($anymatches == 0)
{
echo" back ";
echo "Sorry,Invalid Reservation Number or you are looking at the wrong place double check the number and search it again";
}
{
}
?>
No comments:
Post a Comment