Reading From two list boxes
Posted: Sun Mar 28, 2004 7:41 am
I am currently still working on reading the variables but cannot get the code to work...i have just written the 'search' page in html and the 'results' page in php...here is the code..thanks
<html>
<head><title>Bookday & Week Search</title></head>
<body>
<body BGCOLOR="blue">
<div align="center"><center>
<br>
<table border="1" cellspacing="0" width="700">
<tr>
<td align="center" width="700" bgcolor="red"><h1
align="center" h1><em><b>Search by Bookday And Week</b></em></h1>
</td>
</tr>
<tr>
<form action=""bookday&weekresults.php" method="post">
<td align="center" valign="top" bgcolor="green"
height="67"><p align="center">Select Bookday And Week Number from the Search Lists.
<br> Then Press the Search Button</p>
</td>
</tr>
<tr>
<td height="308">
<form action=""bookday&weekresults.php" method="post">
<br>
<center><h3>Select Bookday:</h3>
<br></center>
<center>Bookday;
<select name="bookday">
<option value="sunday">Sunday</option>
<option value="monday">Monday</option>
<option value="tuesday">Tuesday</option>
<option value="wednesday">Wednesday</option>
<option value="thursday">Thursday</option>
<option value="friday">Friday</option>
<option value="saturday">Saturday</option>
</select>
<br><br>
<center>Week Number;
<select name="weekno">
<option value="1">Week 1</option>
<option value="2">Week 2</option>
<option value="3">Week 3</option>
<option value="4">Week 4</option>
<option value="5">Week 5</option>
</select>
<br><br>
<input type=submit value="search">
</center>
</form>
</td>
</tr>
</table>
</center></div>
</body>
</html>
_______________________________
<html>
<head>
<title>Bookday & Week Results</title>
<body bgcolor="blue">
<h1 align="center"><em>Bookday & Week Results</em></font><h1>
<?
//Connect to database
@ $db=mysql_pconnect ("","");
if(!$db)
{
echo "Error:Could not connect";
exit;
}
mysql_select_db("")
//Run Query for search
$query = "select destinationfrom,destinationtill,price,bookday,weekno
from flights,flightprices where flights.flightid=flightprices.flightid
and flights.flyday=flightprices.flyday and flightprices.bookday='$_POST[bookday]'
and flightprices.weekno='$_POST[weekno]';";
//Count Results
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
if ($num_results == 0) {
echo"<p><strong>No Results Found.<br>Please Try Again</strong></p>";
}
else {
echo "<Hr size=5 width=\"90%\"><br>";
echo "<strong>You Searched for: $bookday & $weekno</strong>";
//List Results
for ($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
}
}
?>
<html>
<head><title>Bookday & Week Search</title></head>
<body>
<body BGCOLOR="blue">
<div align="center"><center>
<br>
<table border="1" cellspacing="0" width="700">
<tr>
<td align="center" width="700" bgcolor="red"><h1
align="center" h1><em><b>Search by Bookday And Week</b></em></h1>
</td>
</tr>
<tr>
<form action=""bookday&weekresults.php" method="post">
<td align="center" valign="top" bgcolor="green"
height="67"><p align="center">Select Bookday And Week Number from the Search Lists.
<br> Then Press the Search Button</p>
</td>
</tr>
<tr>
<td height="308">
<form action=""bookday&weekresults.php" method="post">
<br>
<center><h3>Select Bookday:</h3>
<br></center>
<center>Bookday;
<select name="bookday">
<option value="sunday">Sunday</option>
<option value="monday">Monday</option>
<option value="tuesday">Tuesday</option>
<option value="wednesday">Wednesday</option>
<option value="thursday">Thursday</option>
<option value="friday">Friday</option>
<option value="saturday">Saturday</option>
</select>
<br><br>
<center>Week Number;
<select name="weekno">
<option value="1">Week 1</option>
<option value="2">Week 2</option>
<option value="3">Week 3</option>
<option value="4">Week 4</option>
<option value="5">Week 5</option>
</select>
<br><br>
<input type=submit value="search">
</center>
</form>
</td>
</tr>
</table>
</center></div>
</body>
</html>
_______________________________
<html>
<head>
<title>Bookday & Week Results</title>
<body bgcolor="blue">
<h1 align="center"><em>Bookday & Week Results</em></font><h1>
<?
//Connect to database
@ $db=mysql_pconnect ("","");
if(!$db)
{
echo "Error:Could not connect";
exit;
}
mysql_select_db("")
//Run Query for search
$query = "select destinationfrom,destinationtill,price,bookday,weekno
from flights,flightprices where flights.flightid=flightprices.flightid
and flights.flyday=flightprices.flyday and flightprices.bookday='$_POST[bookday]'
and flightprices.weekno='$_POST[weekno]';";
//Count Results
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
if ($num_results == 0) {
echo"<p><strong>No Results Found.<br>Please Try Again</strong></p>";
}
else {
echo "<Hr size=5 width=\"90%\"><br>";
echo "<strong>You Searched for: $bookday & $weekno</strong>";
//List Results
for ($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
}
}
?>