my update page is not editing the data in the database when I click the submit button. I do not know where I went wrong. I checked the connection to database and its working fine because it is retrieving the previous data.
here is my coding for update page
<?php require_once('Connections/smpiconnection.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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;
}
}
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_computer = 10;
$pageNum_computer = 0;
if (isset($_GET['pageNum_computer'])) {
$pageNum_computer = $_GET['pageNum_computer'];
}
$startRow_computer = $pageNum_computer * $maxRows_computer;
mysql_select_db($database_smpiconnection, $smpiconnection);
$query_computer = "SELECT * FROM maklumat_pc";
$query_limit_computer = sprintf("%s LIMIT %d, %d", $query_computer, $startRow_computer, $maxRows_computer);
$computer = mysql_query($query_limit_computer, $smpiconnection) or die(mysql_error());
$row_computer = mysql_fetch_assoc($computer);
if (isset($_GET['totalRows_computer'])) {
$totalRows_computer = $_GET['totalRows_computer'];
} else {
$all_computer = mysql_query($query_computer);
$totalRows_computer = mysql_num_rows($all_computer);
}
$totalPages_computer = ceil($totalRows_computer/$maxRows_computer)-1;
$queryString_computer = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_computer") == false &&
stristr($param, "totalRows_computer") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_computer = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_computer = sprintf("&totalRows_computer=%d%s", $totalRows_computer, $queryString_computer);
?>
<!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=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
.kl {
font-weight: bold;
}
body {
background-image: url(wooden.jpg);
}
</style>
</head>
<body>
<center>
<p><img src="bannercrop.png" alt="crop" width="1180" height="324" align="middle" longdesc="bannercrop.png" /></p>
<table border="1" cellpadding="1" cellspacing="1">
<tr bgcolor="#33CCCC" class="kl">
<td>Agensi</td>
<td>Jabatan</td>
<td>Work_Group</td>
<td>Computer_Name</td>
<td>Kategori_Infra</td>
<td>Nama_Pengguna</td>
<td>Jawatan</td>
<td>Gred_Jawatan</td>
<td>Kumpulan_Perubatan</td>
<td>Tahun_Perolehan</td>
<td>No_Siri_Komputer</td>
<td>No_Aset</td>
<td>Jenis_OS</td>
<td>Jenama_PC</td>
<td>Model_PC</td>
<td>Model_Monitor</td>
<td>Harga_Infra</td>
<td>Cara_Perolehan</td>
<td>Status_Antivirus</td>
<td>Lesen_Antivirus</td>
<td>Jenama_Antivirus</td>
<td>Status_Penyelenggaraan</td>
<td>Syarikat_Penyelenggaraan</td>
<td>Status_Lan_Pc</td>
<td>Ip_address</td>
<td>Status_Infra</td>
<td>Processor</td>
<td>Ram</td>
<td>Hard_Disk</td>
<td> </td>
</tr>
<?php do { ?>
<tr bgcolor="#FFFF99">
<td><?php echo $row_computer['Agensi']; ?></td>
<td><?php echo $row_computer['Jabatan']; ?></td>
<td><?php echo $row_computer['Work_Group']; ?></td>
<td><?php echo $row_computer['Computer_Name']; ?></td>
<td><?php echo $row_computer['Kategori_Infra']; ?></td>
<td><?php echo $row_computer['Nama_Pengguna']; ?></td>
<td><?php echo $row_computer['Jawatan']; ?></td>
<td><?php echo $row_computer['Gred_Jawatan']; ?></td>
<td><?php echo $row_computer['Kumpulan_Perubatan']; ?></td>
<td><?php echo $row_computer['Tahun_Perolehan']; ?></td>
<td><?php echo $row_computer['No_Siri_Komputer']; ?></td>
<td><?php echo $row_computer['No_Aset']; ?></td>
<td><?php echo $row_computer['Jenis_OS']; ?></td>
<td><?php echo $row_computer['Jenama_PC']; ?></td>
<td><?php echo $row_computer['Model_PC']; ?></td>
<td><?php echo $row_computer['Model_Monitor']; ?></td>
<td><?php echo $row_computer['Harga_Infra']; ?></td>
<td><?php echo $row_computer['Cara_Perolehan']; ?></td>
<td><?php echo $row_computer['Status_Antivirus']; ?></td>
<td><?php echo $row_computer['Lesen_Antivirus']; ?></td>
<td><?php echo $row_computer['Jenama_Antivirus']; ?></td>
<td><?php echo $row_computer['Status_Penyelenggaraan']; ?></td>
<td><?php echo $row_computer['Syarikat_Penyelenggaraan']; ?></td>
<td><?php echo $row_computer['Status_Lan_Pc']; ?></td>
<td><?php echo $row_computer['Ip_address']; ?></td>
<td><?php echo $row_computer['Status_Infra']; ?></td>
<td><?php echo $row_computer['Processor']; ?></td>
<td><?php echo $row_computer['Ram']; ?></td>
<td><?php echo $row_computer['Hard_Disk']; ?></td>
<td><a href="updateprinter.php">update</a></td>
</tr>
<?php } while ($row_computer = mysql_fetch_assoc($computer)); ?>
</table>
<a href="<?php printf("%s?pageNum_computer=%d%s", $currentPage, max(0, $pageNum_computer - 1), $queryString_computer); ?>">Previous</a>
</center>
</body>
</html>
<?php
mysql_free_result($computer);
?>