Thanks for the respond...
i have made some changes but it seems like the database is not updated..
am i doing it right?
Please advice..
<html>
<head>
<title>TimeTable</title>
</head>
<body>
<h1> Here is the timetable</h1>
<?php
@ $db = new mysqli('localhost', 'root', '', 'mylifestyle');
if (mysqli_connect_errno()) {
echo 'Error: Could not connect to database. Please try again later.';
exit;
}
$query = "SELECT course.CourseName , course.Instructor , course.ClassSize , courseschedule.Date ,courseschedule.Time , courseschedule.Location FROM course INNER JOIN courseschedule ON course.CourseID = courseschedule.CourseID";
$result = $db->query($query);
$num_results = $result->num_rows;
echo "<table border='1'>
<tr>
<th>Course Name</th>
<th>Instructor</th>
<th>Class size</th>
<th>Date</th>
<th>Time</th>
<th>Location</th>
<th>Register</th>
</tr>"; ?>
<?php
for ($i=0; $i <$num_results; $i++) {
$row = $result->fetch_assoc();?>
<form method="post" action="haha.php">
<tr>
<td><? echo $row['CourseName']; ?></td>
<td><? echo $row['Instructor']; ?></td>
<td><? echo $row['ClassSize']; ?></td>
<td><? echo $row['Date']; ?></td>
<td><? echo $row['Time']; ?></td>
<td><? echo $row['Location']; ?></td>
<td align="center"><input name="radio" type="radio" id="radio[]" value="<? echo $row['ClassSize']; ?>"></td>
</tr>
<?php
}
?>
<p>
<form method="post" action="<?php echo $PHP_SELF;?>">
<td> <input type = "submit" name="reg" value="Register" /></td>
<input type = "hidden" name="formVar" value="<?php echo $ClassSize?>" />
</form>
</p>
</div>
</body>
</html>
haha.php
<?php
if (!empty($_POST['reg']))
{
$myvarA = $_POST['formVar'];
$ClassSize=$myvarA;
//echo "myvarA= "." $myvarA". "</br>";
if (!get_magic_quotes_gpc())
{
$ClassSize = addslashes($ClassSize);
}
@ $db = new mysqli('localhost', 'root', '', 'mylifestyle');
if (mysqli_connect_errno())
{
echo "Error: Could not connect to database. Please try again later.";
exit;
}
for($i=0;$i <$num_results;$i++){
$del_id = $radio[$i];
$query = "UPDATE course SET ClassSize = ClassSize -1 Where id='$del_id'";
$result = $db->query($query);
if ($result) {
echo "u r reg!<br />";
}
$db->close();
}
}
?>