I can't test it, but it should work :
(be carefull, the copy/past process from a web page could break the code)
<?php
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Seating test</title>
<style type="text/css">
<!--
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
}
body {
margin-left: 0px;
margin-top: 5px;
}
img{
border:0px;
}
-->
</style>
<SCRIPT language=JavaScript>
function confirmBooking() {
if (confirm("The next page will take you to a payment page.\nBooking Fee of £1.50 applies to this transaction.\n\nProceed?")==false)
return false;
else
return true;
}
function deleteBooking() {
if (confirm("The next page will cancel the booking so far.\nYou will have to start again.\n\nProceed?")==false)
return false;
else
return true;
}
<?php
// I generate a javascript array with all the names of the html <SELECT>s
$jsArray = ("var mySelects = Array(");
foreach ($_SESSION['seats'] as $key=>$val) {
$jsArray .= ("'[ $val ]', ");
}
$jsArray = substr($jsArray, 0, -2); // to remove the last ", "
$jsArray .= ");\n";
echo ($jsArray);
?>
function updateTotal()
{
var total = 0;
for (var i = 0; i < mySelects.length; i ++) { // for each select
var mySelect = eval("document.myform.".$mySelects{$i}); // i get the reference of the select
total = total + mySelect{mySelect.selectedIndex}; // the select is an array, so I have to get the selected item
}
// now, i can put the calculated value in the field
document.myform.myTotalField.value = total;
}
</script>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center" class="style1">
<p>Tickets Stage 2 <br>
(see subnote in code):</p>
<p> </p>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<?php
include 'config.php';
$db= mysql_connect($db_host,$db_user,$db_pass) or die (mysql_error());
mysql_select_db ($db_name) or die (mysql_error());
$eventid = $_GET['eventid'];
$datestamp = $_GET['datestamp'];
$query = "SELECT * FROM events WHERE eventid = '$eventid'";
$result=mysql_query($query) or die (mysql_error());
while($r=mysql_fetch_array($result))
{
$id=$r["id"];
$datestamps=$r["datestamp"];
$costadult=$r["costadult"];
$costchild=$r["costchild"];
$costconcession=$r["costconcession"];
}
session_register('eventid');
$_SESSION['eventid'] = $eventid;
session_register('costadult');
$_SESSION['datestamp'] = $datestamp;
session_register('datestamp');
$_SESSION['costadulta'] = $costadult;
session_register('costchild');
$_SESSION['costchilda'] = $costchild;
session_register('costconcession');
$_SESSION['costconcessiona'] = $costconcession;
$eventsid2 = $_SESSION['eventid'];
$datestamp2 =$_SESSION['datestamp'];
// echo "$eventsid2 -> $datestamp2 -> $costadult/$costchild/$costconcession";
?>
<td width="18%"><div align="left"></div></td>
<td width="82%"><p align="left">Event Selected: <strong><?php
mysql_select_db ($db_name) or die (mysql_error());
$query = "SELECT * FROM eventdata WHERE event_id = '$eventid2'";
$result=mysql_query($query) or die (mysql_error());
while($r=mysql_fetch_array($result))
{
$id=$r["id"];
$event_id=$r["event_id"];
$event_date=$r["event_date"];
$event_name=$r["event_name"];
$event_notes=$r["event_notes"];
}
echo "$event_name</strong> [ Event ID : $eventid2 ]";?><br>
Date: <strong><?php
$qt=mysql_query("select * from events");
while($nt=mysql_fetch_array($qt)){
echo "".date("d-m-Y",strtotime($nt[datestamp]))."$nt[datestamp] ";
}
?></strong> <br>
Block: <strong><?php $_GET['block']; echo $block;?></strong><br>
Row: <strong><?php $_GET['row']; echo $row;?></strong><br>
Seat(s): <strong><?php $_GET['seat']; echo $seat;?> - $seat</strong> (or $seat if singular) <br>
<br>
</p>
</td>
</tr>
<tr height="1">
<td></td>
<td background="images/obgg.jpg"></td>
</tr>
<tr>
<td><div align="left"></div></td>
<td><p align="left"><br>
<strong>Ticket BreakDown </strong>(<strong><a href="#" alt="Please chose the appropriate ticket type for each seat chosen.">?</a></strong>)</p>
<p align="left"><?php echo "$block$row$seat";?>
<?php
echo "<form name=\"myform\">";
foreach ($_SESSION['seats'] as $key=>$val)
{
// get seat data
$query = "SELECT * FROM arena WHERE seat_id = '$val'";
$result=mysql_query($query) or die (mysql_error());
while($r=mysql_fetch_array($result)) {
$id=$r["id"];
$seat_id=$r["seat_id"];
$ticket_block=$r["block"];
$ticket_row=$r["row"];
$ticket_seat=$r["seat"];
$costadultb=$r["costadult"];
$costchildb=$r["costchild"];
$costconcessionb=$r["costconcession"];
}
// re-defining ticket cost sessions
$ticket_full = "$ticket_block$ticket_row$ticket_seat";
echo "<table width=\"50%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<td width=\"15%\">$ticket_full -> </td>
<td> <select name=\"[ $seat_id ]\" class=\"style1\" onchange='updateTotal();'>
<option value=\"none\" selected>-- Please Choose Ticket Type --</option>
<option value=\"$costadultb\">Adult @ [ £$costadultb ]</option>
<option value=\"costchildb\">Child @ [ £$costchildb ]</option>
<option value=\"costconcessionb\">Concession @ [ £$costconcessionb ]</option>
</select><br><br></td>
</tr>
</table>";
// Select data from Database where seats_id = the id taken from the session is 0001 for block A row A seat 1
}
?>
Ticket Total: <input type=text value="£0.00" name="myTotalField" class="style1" disabled='disabled'></form>
</p>
<p align="left"><br>
<br>
Booking Fee:£<?php echo $bfee = "1.50"; "$bfee";?></p>
<?php
function makeRandomPassword() {
$salt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabchefghjkmnpqrstuvwxyz0123456789";
srand((double)microtime()*1000000);
$i = 0;
while ($i <= 8) {
$num = rand() % 33;
$tmp = substr($salt, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
$random_id = makeRandomPassword();
?>
<p align="left"><a href='booking.php?<?php echo "event=$event_id&id=$random_id";?>&confirmid=<?php echo session_id();?>' onclick='return confirmBooking()' class='style1'><strong>Proceed</strong></a> | <a href='start_over.php?start_over&confirmid=<?php echo session_id();?>' onclick='return deleteBooking()' class='style1'><strong>Cancel</strong></a></p></td>
</tr>
</table>
<p> </p>
</div></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center">
<?php include 'footer.php';?>
</div>
<div align="center"></div></td>
</tr>
</table>
<p> </p>
<p align="center" class="style1"> </p>
<p> </p>
</body>
</html>