|
|
|
ช่วยหน่อยครับ ทำหน้าอัปเดท แต่ฟิว isbn อัปเดทไม่ได้ครับ |
|
|
|
|
|
|
|
Code (PHP)
<?php require_once('Connections/dbconn.php'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "Login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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"] == "fmUpdate")) {
$updateSQL = sprintf("UPDATE books SET title=%s, author=%s, adviser=%s, `year`=%s, description=%s, Picture_Book=%s, Picture_chapter=%s, Picture_Editorial=%s, catid=%s, instock=%s, status=%s WHERE isbn=%s",
GetSQLValueString($_POST['title'], "text"),
GetSQLValueString($_POST['author'], "text"),
GetSQLValueString($_POST['adviser'], "text"),
GetSQLValueString($_POST['year'], "text"),
GetSQLValueString($_POST['description'], "text"),
GetSQLValueString($_POST['Picture_Book'], "text"),
GetSQLValueString($_POST['Picture_chapter'], "text"),
GetSQLValueString($_POST['Picture_Editorial'], "text"),
GetSQLValueString($_POST['catid'], "text"),
GetSQLValueString($_POST['instock'], "int"),
GetSQLValueString($_POST['status'], "text"),
GetSQLValueString($_POST['key_isbn'], "text"));
mysql_select_db($database_dbconn, $dbconn);
$Result1 = mysql_query($updateSQL, $dbconn) or die(mysql_error());
$updateGoTo = "updateok.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "fmUpdate")) {
$updateSQL = sprintf("UPDATE books SET title=%s, author=%s, adviser=%s, `year`=%s, description=%s, Picture_Book=%s, Picture_chapter=%s, Picture_Editorial=%s, catid=%s, instock=%s, status=%s,isbn=%s WHERE isbn=%s",
GetSQLValueString($_POST['title'], "text"),
GetSQLValueString($_POST['author'], "text"),
GetSQLValueString($_POST['adviser'], "text"),
GetSQLValueString($_POST['year'], "text"),
GetSQLValueString($_POST['description'], "text"),
GetSQLValueString($_POST['Picture_Book'], "text"),
GetSQLValueString($_POST['Picture_chapter'], "text"),
GetSQLValueString($_POST['Picture_Editorial'], "text"),
GetSQLValueString($_POST['catid'], "text"),
GetSQLValueString($_POST['instock'], "int"),
GetSQLValueString($_POST['isbn'], "text"),
GetSQLValueString($_POST['key_isbn'], "text"));
mysql_select_db($database_dbconn, $dbconn);
$Result1 = mysql_query($updateSQL, $dbconn) or die(mysql_error());
$updateGoTo = "updateok.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_rsemp = "-1";
if (isset($_GET['isbn'])) {
$colname_rsemp = (get_magic_quotes_gpc()) ? $_GET['isbn'] : addslashes($_GET['isbn']);
}
mysql_select_db($database_dbconn, $dbconn);
$query_rsemp = sprintf("SELECT * FROM books WHERE isbn = '%s' ORDER BY isbn ASC", $colname_rsemp);
$rsemp = mysql_query($query_rsemp, $dbconn) or die(mysql_error());
$row_rsemp = mysql_fetch_assoc($rsemp);
$totalRows_rsemp = mysql_num_rows($rsemp);
?>
<!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=windows-874" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-image: url(img/clound.gif);
}
#Layer1 {
position:absolute;
left:134px;
top:207px;
width:835px;
height:13px;
z-index:1;
}
#Layer2 {
position:absolute;
left:552px;
top:625px;
width:538px;
height:23px;
z-index:2;
}
-->
</style>
</head>
<body>
<div id="Layer1">
<marquee>ยินดีต้อนรับท่านเข้าสู่ Web site ระบบยืม - คืนและจัดดรรชนีปริญญนิพนธ์ </marquee></div>
<table width="1023" border="0" align="center" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="200" colspan="3"><img src="img/HeaddJA.jpg" width="1200" height="200" border="0" usemap="#Map" /></td>
</tr>
<tr>
<td height="30" colspan="3" valign="top"><img src="img/middle.jpg" width="1200" height="30" /></td>
</tr>
<tr>
<td width="237" height="42" valign="top"><img src="img/google-search1.gif" width="235" height="42" /></td>
<td width="42"> </td>
<td width="921"> </td>
</tr>
<tr>
<td height="30" valign="top"><form action="http://www.google.co.th/search" method="get" name="form2" target="_self" id="form2">
<input name="q" type="text" id="q" size="24" maxlength="24" />
<input type="submit" name="Submit" value="Go" id="Submit" />
</form></td>
<td> </td>
<td valign="top">
<link href="css/master.css" rel="stylesheet" type="text/css" /><style type="text/css">
<!--
.style1 {color: #000000;
font-weight: bold;
font-size: 24px;
}
.style2 {font-size: 18px;
font-weight: bold;
color: #000066;
}
-->
</style>
<strong>แก้ไขข้อมูลปริญญานิพนธ์</strong></td>
</tr>
<tr>
<td rowspan="2" valign="top"><p>
<embed src="http://i110.photobucket.com/albums/n100/b810/clock/Set2%20150x150/f2.swf" width="235" height="160" wmode="transparent" quality="high" loop="True" bgcolor="#000000" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></p> </td>
<td height="83"> </td>
<td rowspan="4" valign="top"><p align="center"> <a href="list1.php"><font color="#000033">แสดงข้อมูล</font></a> <a href="resultadv.php"><font color="#000033">ค้นหา</font></a> <a href="insert.php"><font color="#000033">เพิ่มข้อมูล</font></a> <a href="logout.php"><font color="#000033">Log out</font></a></p>
<form action="<?php echo $editFormAction; ?>" method="post" name="fmUpdate" id="fmUpdate">
<table width="700" border="0" cellpadding="2" cellspacing="1" bgcolor="#993300">
<tr bgcolor="#FFE5B2">
<td align="right" nowrap="nowrap" bgcolor="#FFE5B2" class="detaillabels">รหัสหนังสือ :</td>
<td bgcolor="#FFE5B2"><label for="textfield"></label>
<input name="isbn" type="text" id="isbn" value="<?php echo $row_rsemp['isbn']; ?>" /></td>
</tr>
<tr bgcolor="#FFE5B2">
<td width="20%" align="right" nowrap="nowrap" bgcolor="#FFE5B2" class="detaillabels">ชื่อเรื่อง :</td>
<td bgcolor="#FFE5B2"><input name="title" type="text" id="title" value="<?php echo $row_rsemp['title']; ?>" /></td>
</tr>
<tr>
<td align="right" nowrap="nowrap" bgcolor="#FFE5B2" class="detaillabels">ผู้จัดทำ :</td>
<td bgcolor="#FFE5B2"><input name="author" type="text" id="author" value="<?php echo $row_rsemp['author']; ?>" /></td>
</tr>
<tr>
<td align="right" nowrap="nowrap" bgcolor="#FFE5B2" class="detaillabels">อาจารย์ที่ปรึกษา</td>
<td bgcolor="#FFE5B2"><label for="textfield"></label>
<input name="adviser" type="text" id="adviser" value="<?php echo $row_rsemp['adviser']; ?>" /></td>
</tr>
<tr>
<td align="right" nowrap="nowrap" bgcolor="#FFE5B2" class="detaillabels">ปี พ.ศ. :</td>
<td bgcolor="#FFE5B2"><input name="year" type="text" id="year" value="<?php echo $row_rsemp['year']; ?>" /></td>
</tr>
<tr>
<td align="right" nowrap="nowrap" bgcolor="#FFE5B2" class="detaillabels">รายละเอียด:</td>
<td bgcolor="#FFE5B2"><input name="description" type="text" id="description" value="<?php echo $row_rsemp['description']; ?>" /></td>
</tr>
<tr>
<td align="right" nowrap="nowrap" bgcolor="#FFE5B2" class="detaillabels">รหัสหมวดหมู่:</td>
<td bgcolor="#FFE5B2"><input name="catid" type="text" id="catid" value="<?php echo $row_rsemp['catid']; ?>" /></td>
</tr>
<tr>
<td align="right" nowrap="nowrap" bgcolor="#FFE5B2" class="detaillabels"> คงคลัง:</td>
<td bgcolor="#FFE5B2"><input name="instock" type="text" id="instock" value="<?php echo $row_rsemp['instock']; ?>" /></td>
</tr>
<tr>
<td align="right" nowrap="nowrap" bgcolor="#FFE5B2" class="detaillabels">สถานะ:</td>
<td bgcolor="#FFE5B2"><input name="status" type="text" id="status" value="<?php echo $row_rsemp['status']; ?>" /></td>
</tr>
<tr>
<td align="right" nowrap="nowrap" bgcolor="#FFE5B2" class="detaillabels">หน้าปก:</td>
<td bgcolor="#FFE5B2"><input name="Picture_Book" type="text" id="Picture_Book" value="<?php echo $row_rsemp['Picture_Book']; ?>" /></td>
</tr>
<tr>
<td align="right" nowrap="nowrap" bgcolor="#FFE5B2" class="detaillabels">บทคัดย่อ:</td>
<td bgcolor="#FFE5B2"><input name="Picture_Editorial" type="text" id="Picture_Editorial" value="<?php echo $row_rsemp['Picture_Editorial']; ?>" /></td>
</tr>
<tr>
<td align="right" nowrap="nowrap" bgcolor="#FFE5B2" class="detaillabels">บทที่ 1: </td>
<td bgcolor="#FFE5B2"><input name="Picture_chapter" type="text" id="Picture_chapter" value="<?php echo $row_rsemp['Picture_chapter']; ?>" /></td>
</tr>
<tr>
<td align="right" nowrap="nowrap" bgcolor="#FFE5B2" class="detaillabels"> </td>
<td bgcolor="#FFE5B2"> </td>
</tr>
</table>
<table width="16%" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td>
<div align="center">
<input name="Submit" type="submit" id="Submit" value="บันทึก" />
<input name="Reset" type="reset" id="Reset" value="ยกเลิก" />
<input name="key_isbn" type="hidden" id="key_isbn" value="<?php echo $row_rsemp['isbn']; ?>" />
<input type="hidden" name="MM_update" value="fmUpdate" />
</div></td>
</tr>
</table>
<p> </p>
</form>
<p> </p></td>
</tr>
<tr>
<td height="77"> </td>
</tr>
<tr>
<td height="16"></td>
<td></td>
</tr>
<tr>
<td height="208" valign="top"><embed src="http://i172.photobucket.com/albums/w2/nbee_flash/calendar/NB8.swf" width="237" height="208" wmode="transparent" quality="high" loop="True" bgcolor="#000000" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></td>
<td></td>
</tr>
<tr>
<td colspan="3" valign="top"><img src="img/footer4.jpg" width="1200" height="100" /></td>
</tr>
<tr>
<td height="5"></td>
<td></td>
<td></td>
</tr>
</table>
<map name="Map" id="Map">
<area shape="rect" coords="843,160,958,195" href="Login.php" target="_parent" alt="ผู้ดูแลระบบ" />
<area shape="rect" coords="702,160,817,195" href="contect.php" target="_parent" alt="ติดต่อเรา" />
<area shape="rect" coords="562,160,677,195" href="Instructions.php" target="_parent" alt="แนะนำการใช้งาน" />
<area shape="rect" coords="423,160,538,195" href="Service.php" target="_parent" alt="บริการยืม-คืน" />
<area shape="rect" coords="283,160,398,195" href="resultadv.php" target="_parent" alt="สืบค้นหนังสือ" />
<area shape="rect" coords="142,159,257,194" href="Index.php" target="_parent" alt="หน้าแรก" />
<area shape="rect" coords="89,7,662,65" href="http://www.rmutp.ac.th" target="_blank" alt="มทร.พระนคร" />
</map>
</body>
</html>
<?php
mysql_free_result($rsemp);
?>
ขอถามหน่อยครับ ทำไม ['isbn'] ถึงแก้ไขแล้วค่ามันไม่เปลี่ยน ช่วยหน่อยครับ ทำในดรีม
Tag : PHP
|
|
|
|
|
|
Date :
2011-08-15 22:05:37 |
By :
momanclub |
View :
816 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
echo $updateSQL;
exit();
ดูที่ SQL Statement ครับ ได้อะไรลองเอามาดูครับ
|
|
|
|
|
Date :
2011-08-16 06:32:03 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตามพี่วินบอกเลยครับ echo $updateSQL;
แล้วลองตรวจสอบดูจำพวกเครื่องหมายต่างๆ ว่า ขาดหรือเกินมาหรือไม่ หรือฟิลด์ไหนเป็นค่าว่างมันไม่ส่งค่ามาก้อไปแก้ที่ฟิลด์นั้น
แต่ส่วนมากผมจะคัดลอกผลลัพธ์ที่ echo ออกมาไปวางใน phpMyadmin แล้วเช็คดูครับว่าโค้ดส่วนไหนไม่ถูกต้อง
|
|
|
|
|
Date :
2011-08-16 10:26:33 |
By :
HaKonNan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ก่อนอื่นต้องขอบคุณพี่ ๆ ทั้งสองก่อนนะครับ
เดี่ยวจะลองดูก่อน
แต่รบกวนถาม การเรื่องตัดสต๊อกหน่อยนะครับ พอจะมีโค้ดตัวอย่างไหมครับ จะทำการยืม คืน หนังสือ
|
|
|
|
|
Date :
2011-08-17 00:42:25 |
By :
momanclub |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|