my program cannot update the value,but it can show the value of the database
Thank you
<?php require_once('../Connections/connection.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE student_info SET student_e=%s, present_time=%s WHERE id=%s",
GetSQLValueString($_POST['student_e'], "text"),
GetSQLValueString($_POST['id'], "int"),
GetSQLValueString($_POST['present_time'], "int"));
mysql_select_db($database_connection, $connection);
$Result1 = mysql_query($updateSQL, $connection) or die(mysql_error());
}
$colname_Recordset1 = "-1";
if (isset($_GET['id'])) {
$colname_Recordset1 = $_GET['id'];
}
mysql_select_db($database_connection, $connection);
$query_Recordset1 = sprintf("SELECT * FROM student_info WHERE id = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $connection) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<title>Untitled Document</title>
</head>
<body>
<form action="<?php echo $editFormAction; ?>" id="form1" name="form1" method="POST">
<p><?php echo $row_Recordset1['student_e']; ?></p>
Present
<label>
<input <?php if (!(strcmp($row_Recordset1['present_time'],"1"))) {echo "checked=\"checked\"";} ?> type="radio" name="present_time" id="1" value="1" />
</label>
Late
<label>
<input <?php if (!(strcmp($row_Recordset1['present_time'],"2"))) {echo "checked=\"checked\"";} ?> type="radio" name="present_time" id="2" value="2" />
</label>
Leave Early
<label>
<input <?php if (!(strcmp($row_Recordset1['present_time'],"3"))) {echo "checked=\"checked\"";} ?> type="radio" name="present_time" id="3" value="3" />
</label>
Absent
<label>
<input <?php if (!(strcmp($row_Recordset1['present_time'],"4"))) {echo "checked=\"checked\"";} ?> type="radio" name="present_time" id="4" value="4" />
</label>
<label>
<input type="submit" name="Submit" value="Submit" />
</label>
<p> </p>
<p>
</p>
<input type="hidden" name="MM_update" value="form1" />
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>