Hello there I have kinda got gotten myself into a sticky situation. I am trying to do something which seams too big to do in my head but I feel I kinda know how to do it.
My problem is I have a website and and users come in and book a court. There are three courts, and on the first page ill have up its a table which they choose which court they want then they go to a new page which is also a table.
The second page has three values to fill in on the form, the first is the member no, the second is the court which is already defaulted to the court and the final is the time slot. I wish to have the time slot number in a drop down option box where there should be a if statment saying if in the court table member number is blank or "" then print out all the time slots(where member no is blank). It should hide the rest.
The third and final table is just used to update the information into the table and replace the timeslot and court with the new time slot, court and member number.
I hope I have explained my self enough if not i will try again sorry.
Code for the first page (choosing court)
[HTML]<html>
<br>
<br>
<head>
<h1><font face="sans-serif, Arial" font color="white">Update Court Page!</h1>
</head>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<body background="main background1.jpg" link="blue" vlink="blue">
<table width="350" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td>
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td colspan="3" align="center"><strong><font face="sans-serif, Arial" font color="white">Please Choose A Court</strong></td>
</tr>
<tr>
<td><form id="form1" name="form1" method="post"><font face="sans-serif, Arial" font color="white">Court No</td>
<td><font color="white">:</td>
<td><select name="court" id="court">
<option>-----------------------</option>
<option value="Fcourt1">Football court 1</option>
<option value="Fcourt2">Football court 2</option>
<option value="Bcourt">Basketball court </option>
</select>
<input type="submit" name="Submit" value="Submit"/>
</form>
</td>
</tr>
</table>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$court = $_POST['court'];
switch ($court)
{
case "Fcourt1":
require_once("fcourt1.php");
//echo $var;
break;
Case "Fcourt2":
require_once("fcourt2.php");
//echo $var;
break;
Case "Bcourt":
require_once("bcourt.php");
//echo $var;
break;
}
}
?>
</body>
</html> [/HTML]
Code for second page the if statement
[PHP]<?php
// this starts the session
session_start();
?>
<html>
head>
</head>
<?php
$db_name="project"; // Database name
$tbl_name="bcourt"; // Table name
// Connect to server and select database.
mysql_connect($_SESSION['host'], $_SESSION['username'], $_SESSION['password'])or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Get values from form
$memberno1=$_GET['Member_No'];
$courtno1=$_GET['Court_No'];
$TSN1=$_GET['Time_Slot_No'];
<body background="main background1.jpg" link="blue" vlink="blue">
<table width="350" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td><form name="Update Network Gaming form" method="post" action="updatebcourt_ac.php">
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td colspan="3" align="center"><strong><font face="sans-serif, Arial" font color="white">Insert Data Into mySQL Database </strong></td>
</tr>
<tr>
<td><font face="sans-serif, Arial" font color="white">Member No</td>
<td><font color="white">:</td>
<td><input name="Member_No" type="int" id="Member_No"></td>
</tr>
<tr>
<td><font face="sans-serif, Arial" font color="white">Court No</td>
<td><font color="white">:</td>
<td><input name="Court_No" type="varchar" id="Court_No" value="Bcourt"></td>
</tr>
<tr>
<td><font face="sans-serif, Arial" font color="white">Time Slot No</td>
<td>:</td>
<td><select value="please choose a Date" name="Time_Slot_No" size="1" >
if ( 'Member_No' == ""){
//<option value=$rows['Time_Slot_No']</option>
<option value=$TSN1</option>
}
</select></td>
</tr>
<td colspan="3" align="center"><input type="submit" name="Submit" value="Continue"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
// close connection
mysql_close();
?>
</body>
</html>[/PHP]
The final page which works fine. Just showing incase you need to see the code.
[PHP]<?php
// this starts the session
session_start();
?>
<?php
$db_name="project"; // Database name
$tbl_name="court"; // Table name
// Connect to server and select database.
mysql_connect($_SESSION['host'], $_SESSION['username'], $_SESSION['password'])or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Get values from form
$memberno=$_POST['Member_No'];
$courtno=$_POST['Court_No'];
$TSN=$_POST['Time_Slot_No'];
// Insert data into mysql
$sql="INSERT INTO $tbl_name(Member_No, Court_No, Time_Slot_No)VALUES('$memberno', '$courtno', '$TSN')";
$result=mysql_query($sql);
// if successfully insert data into database, displays message "Successful".
if($result){
header('Location: blank.php');
}
else {
echo "ERROR";
}
// close connection
mysql_close();
?>
<?php
$db_name="project"; // Database name
$tbl_name="bcourt"; // Table name
// Connect to server and select database.
mysql_connect($_SESSION['host'], $_SESSION['username'], $_SESSION['password'])or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Get values from form
$memberno=$_POST['Member_No'];
$courtno=$_POST['Court_No'];
$TSN=$_POST['Time_Slot_No'];
// Insert data into mysql
$sql="INSERT INTO $tbl_name(Member_No, Court_No, Time_Slot_No)VALUES('$memberno', '$courtno', '$TSN')";
$result=mysql_query($sql);
// if successfully insert data into database, displays message "Successful".
if($result){
header('Location: blank.php');
}
else {
echo "ERROR";
}
// close connection
mysql_close();
?>[/PHP]
I have tried to get the vale to go in the option section two ways but I need it to like show al data. Is the task too big?
Thank you for any advice in advanced. Looks challenging :D