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);
}
}
?>
Reading From two list boxes
Moderator: General Moderators
Re: Reading From two list boxes
Code: Select all
<?php
$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]';";
?>Code: Select all
<?php
$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]}';";
?>- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Re: Reading From two list boxes
It shouldn't do, unquoted array elements in a double quoted string should be fine. If you use curly brackets then you should quote the element name.Deemo wrote:In your Query (above), you say '$_POST[weekno]'. That will give you a mysql error
Mac
is
a typo?
should be
Code: Select all
<form action=""bookday&weekresults.php" method="post">should be
Code: Select all
<form action="bookday&weekresults.php" method="post">