HI
I am trying to create a fare calculator for trams using a PHP form. This is what I have done so far;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
<?php
$raw_station = $_REQUEST["station"];
$station = stripslashes($raw_station); //needed to remove slashes before '
?>
</TITLE>
</HEAD>
<?php
// make db connection
$conn = pg_connect("host=pgdbs8 user=wwwuser dbname=dwt password=wwwuser");
if (!$conn)
{
echo "<H1>ERROR - no DB connection</H1>\n";
exit;
}
?>
<html><body>
<h4>Fare calculator</h4>
<p>Choose stations</p>
<p>From:</p>
<form action="process.php" method="post">
<select name="from"> <option>Choose Station </option>
<option>City Square </option>
<option>Headrow </option>
<option>University </option>
<option>Hyde Park </option>
<option>Headingley </option>
<option>West Park </option>
<option>Bodington </option>
</select>
<p>To:</p>
<select name="to"> <option>Choose Station </option>
<option>City Square </option>
<option>Headrow </option>
<option>University </option>
<option>Hyde Park </option>
<option>Headingley </option>
<option>West Park </option>
<option>Bodington </option>
</select>
<p>
<br>
Number of Adults..
<input name="from2" type="text" maxlength="1" />
<br>
<br> Number of Children <input name="To" type="text" maxlength="1">
</br>
</br>
</p>
<p>
<br><input type=radio name=city value="='single ticket'"> Single ticket </br>
<br><input type=radio name=city value="='return tickets'"> Return ticket </br>
</p>
<p>
<input type=submit value= "Calculate fare" />
<INPUT TYPE=RESET value= "clear">
</p>
</form>
</body></html>
<body>
</body>
</html>
I have 2 menu boxes that selects stations from and to for users. two text fields for a user to select the numbe of children and adults. to radio buttons for the user to select if the ticket is return or single.
These are the two tabels I have to retrieve information from;
station_zone
Station Zone
City Square 0
Headrow 0
Hyde Park 1
West Park 2
Bodington 2
University 1
Headingley 2
zone_cost
Zone Difference Cost (in pence)
0 50
1 125
2 150
I am new at PHP and my question is how to I retrive information from the table using the PHP form to get the fare price? is it possible to have multiple sql queries? another question is, i do not have the table to single or return tickets and I have been told we are only allowed to use the two tables that we have given. In an