ok i have adapted the code
its like this now
<?PHP
ob_start();
$host = "localhost";
$user = "*********";
$pass = "**********";
$db = "***********";
$conn = mysql_connect($host, $user, $pass)
OR DIE (mysql_error());
@mysql_select_db ($db, $conn) OR DIE (mysql_error());
echo $date_ID;
$sqldate ="select date from calender where cal_ID =".$date_ID;
$result=mysql_query($sqldate);
$sqlID ="select cal_ID from calender where cal_ID =".$date_ID;
$resultID=mysql_query($sqlID);
list ($listID) = mysql_fetch_array ($resultID);
list ($resultID) = mysql_fetch_array ($result);
echo "listID = $listID";
echo "resultid = $resultID";
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
# escape data and set variables
$Datecooking = ($_POST["date"]);
$people = ($_POST["people"]);
$datebooking = ($_POST["booking"]);
$who = ($_POST["who"]);
$price = ($_POST["price"]);
$cal_ID = ($_POST["cal_ID"]);
$query = "INSERT INTO details"
. "(cal_ID, price, date, number, who) ";
$query.= "VALUES (";
$query.= "'$listID', '$price', '{$datebooking}', '$people', '$who')";
$answer = mysql_query($query);
$sqlsoldadapt = "Select sold from calender where cal_ID =".$date_ID;
$soldadaptresult= mysql_query($sqlsoldadapt);
$soldadapt=mysql_result($result,$i,"sold");
$newsold = $soldadapt + $people;
$sqlnewsold =" UPDATE calender SET sold='newsold' WHERE cal_ID=".$date_ID;
mysql_query($sqlnewsold);
$URL="http://www.***********.com/bookings/";
header ("Location: $URL");
ob_end_flush();
# check for error
if (mysql_error()) { print "Database ERROR: " . mysql_error(); }
}
?>
<form name="fa" action="add.php" method="POST">
<table>
<tr><td><b>DATE of cooking class</b> </td><td><? echo $resulttest ?></td></tr>
<tr><td><b>number of people </b> </td><td><input type="text" name="people" size=2></td></tr>
<tr><td><b>Price</b> </td><td><input type="text" name="price" size=2></td></tr>
<tr><td><b>date of booking</b> </td><td><input type="text" name="booking" size=10></td></tr>
<tr><td valign=top><b>booked by </td><td> Travelbar <INPUT NAME="who" TYPE=radio VALUE="travelbar">
The Shop<INPUT NAME="who" TYPE=radio VALUE="The Shop">
</td></tr>
<tr><th colspan=2><p><input type="submit" value="Add Record"></p></th></tr>
</table>
</form>
it doesnt work! there is 2 problems.. the first is dat the cal_id is not entered into the database.. instead the default value of 0 seems to be inserted..
the variable $listID seems to get reset when submit is pressed.
the second problem is that all the values in the database get overwritten with the last form values...
help!!! its driving me insane..