<html>
<head>
<title>Canteen Orders</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
function ShowOrder(theOption){
alert ("You have ordered " + theOption[theOption.selectedIndex].value +" "+theOption.name);
}
var orders =
new Array();
var products =
new Array();
function LoadOrderArray(theForm){
for (i=0;i<document.orderform.elements.length-3;i++){//process the form to give a total in the box
qty = document.orderform.elements[i].value;
if (qty > 0){
productno = document.orderform.elements
[count].value;
products
[count] = productno;
} //ends the if
}//ends the for loop
// document.orderform.orderarray.value = orders;
// document.orderform.productsarray.value = products;
alert ("thank you for you order " );
return true;
}
</script>
</head>
<body bgcolor="#00CC00">
<?php
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="CANTEEN"; // Database name
$tbl_name="STUDENT"; // Table name
// username and password sent from form
$username=$_GET['StudentName'];
$sql="SELECT * FROM student WHERE STUDENTID='$username'";
echo "<BR> the user name is ";
_SESSION['studentsname']=$row['FIRSTNAME'];
//$current = session_register("username");
$sql="SELECT * FROM STUDENT WHERE STUDENTID='$username'";
echo "<input type = \"hidden\" name = \"StudentName\" value =\" ";
if ($count==0){
}else{
$FName = $row['FIRSTNAME'];
$LName = $row['LASTNAME'];
echo "Welcome to Lunch Orders R us ";
}
?>
<form action="backup/studentchangepassword.php" method="get" name="form3" target="mainFrame" >
<input type="submit" name="Submit3" value="Change Password">
</form>
<form action="processorders.php?order=" method = "get" name="orderform" onSubmit="LoadOrderArray(this)">
<?php
$hot = "Yes";
$cat = "Savory";
$ordersql="SELECT PRODUCTID, PRODUCTNAME, CATEGORY, PRICE, HOT FROM PRODUCTS ORDER BY CATEGORY";
echo "<table border = '1'><tr><TD> Qty <TD> Product Name <TD> Category <TD> Price <TD> Hot ";
{
if ($row['HOT']=="Y")
$hot = "Yes";
else
$hot = "No";
switch ($row['CATEGORY']){
case 1: $cat = "Savory"; break;
case 2: $cat = "Sweet"; break;
case 3: $cat = "Drink"; break;
default: $cat="Unknown";
}//ends the switch
<TD> <select name = '{$row['PRODUCTNAME'] } ' onChange='ShowOrder(this)'><option value = 0>0<option value = 1>1<option value = 2>2 <option value = 3>3</select>
<input type = 'hidden' name = '{$row['PRODUCTID']}' VALUE = '{$row['PRODUCTID']}'>
<TD> {$row['PRODUCTNAME']}
<TD> {$cat}
<TD> {$row['PRICE']}
<TD> {$hot} ";
} //ends the while
echo "<TR><TD colspan = '6'> ";
?>
<input type = "hidden" name = "orderarray">
<input type = "hidden" name = "productarray">
Total: <input type = "text" name ="Total">
<input type ="submit" name ="submit" value = "Process your order" onClick="LoadOrderArray(this)" >
</form>
</body>
</html>