|
 |
|
ช่วยด้วยครับ อัพเดทข้อมูลใน mysql ไม่ได้ ผู้รู้ช่วยเซ็คให้หน่อยครับ PHP มือใหม่ครับ ใช้ Appserv v2.5.10 XPครับ |
|
 |
|
|
 |
 |
|
/////////////////////////////////////// ไฟล์ Copy_Edit.php
Code (PHP)
<?php
@session_start();
?>
<!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" />
<?php
//------------------------------------------------------------------------------
if(!isset($_SESSION['Sess_Id']))//ตรวจสอบการเข้าใช้งานระบบ
{
echo"คุณกำลังเข้าใช้งานระบบในส่วนที่ไม่ได้รับอนุญาติ";
exit();
}
//------------------------------------------------------------------------------
include"../Contact/conn.php";
$sql = "SELECT
copy.id,
copy.contactno,
copy.productno,
copy.name,
copy.employee,
copy.gold,
copy.gold_w,
copy.elec,
copy.elec_b,
copy.elec_m,
copy.more,
copy.sale,
copy.sale_f,
copy.sale_d,
copy.sale_d2,
copy.sale_d3,
copy.sale_p,
copy.sale_p2,
copy.sale_p3,
copy.sale_m,
copy.name2,
copy.name2_nik,
copy.job,
copy.name_married,
copy.name_married_nik,
copy.name_guarantee,
copy.name_guarantee_nik,
copy.date FROM copy WHERE id = '".$_GET['View']."' ";
/*$sql = "SELECT * FROM copy WHERE id = '".$_GET['View']."' ";
*/$query = mysql_query($sql);
$dep_kui = mysql_result($query,0,"id");
?>
<script type="text/javascript" src="date.js"></script>
</head>
<body>
<form id="form1" name="form1" method="post" action="Copy_Edit2.php">
<table width="100%" border="1" cellspacing="0" cellpadding="2">
<tr>
<td colspan="2" align="center" valign="middle" bgcolor="#CCCC99">(แก้ไขสำเนา)</td>
</tr>
<tr>
<td width="24%" align="right" valign="middle">เลขที่สัญญา</td>
<td width="76%" valign="middle"><input name="Contactno" type="text" id="Contactno" value="<?php echo mysql_result($query,0,'Contactno') ;?>" size="30" /></td>
</tr>
<tr>
<td width="24%" align="right" valign="middle">รหัสสินค้า</td>
<td valign="middle"><input name="productno" type="text" id="productno" value="<?php echo mysql_result($query,0,'productno') ;?>" size="30" /></td>
</tr>
<tr>
<td align="right" valign="middle">ชื่อผู้ซื้อ</td>
<td valign="middle"><input name="name" type="text" id="name" value="<?php echo mysql_result($query,0,'name') ;?>" size="30" /></td>
</tr>
<tr>
<td align="right" valign="middle">พนักงานขาย</td>
<td valign="middle"><input name="employee" type="text" id="employee" value="<?php echo mysql_result($query,0,'employee') ;?>" size="30" /></td>
</tr>
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
<tr>
<td align="right" valign="middle"> </td>
<td valign="middle"><input type="submit" name="button" id="button" value="Update" onclick="return confirm('คุณแน่ใจหรือไม่ ที่จะบันทึกการแก้ไขข้อมูลนี้!!!');" />
<input type="reset" name="button2" id="button2" value="Reset" onclick="return confirm('คุณแน่ใจหรือไม่ ที่จะไม่บันทึกข้อมูลนี้!!!');" /></td>
</tr>
</table>
</form>
</body>
</html>
########################################################################### ไฟล์ Copy_Edit2.php
<?php error_reporting("E_ALL");?>
<!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" />
<?php
@session_start();
if(!isset($_SESSION['Sess_Id']))//ตรวจสอบการเข้าใช้งานระบบ
{
echo"คุณกำลังเข้าใช้งานระบบในส่วนที่ไม่ได้รับอนุญาติ";
exit();
}
//------------------------------------------------------------------------------
if(isset($_POST['button']) and $_POST['name'] !="")//Check
{
include"../Contact/conn.php";
/* $sql = "UPDATE copy SET
copy.Contactno,
copy.productno,
copy.name,
copy.employee,
copy.gold,
copy.gold_w,
copy.elec,
copy.elec_b,
copy.elec_m,
copy.more,
copy.sale,
copy.sale_f,
copy.sale_d,
copy.sale_d2,
copy.sale_d3,
copy.sale_p,
copy.sale_p2,
copy.sale_p3,
copy.sale_m,
copy.name2,
copy.name2_nik,
copy.job,
copy.name_married,
copy.name_married_nik,
copy.name_guarantee,
copy.name_guarantee_nik,
copy.date)
VALUES('".$_POST['Contactno']."',
'".$_POST['productno']."',
'".$_POST['name']."',
'".$_POST['employee']."',
'".$_POST['gold']."',
'".$_POST['gold_w']."',
'".$_POST['elec']."',
'".$_POST['elec_b']."',
'".$_POST['elec_m']."',
'".$_POST['more']."',
'".$_POST['sale']."',
'".$_POST['sale_f']."',
'".$_POST['sale_d']."',
'".$_POST['sale_d2']."',
'".$_POST['sale_d3']."',
'".$_POST['sale_p']."',
'".$_POST['sale_p2']."',
'".$_POST['sale_p3']."',
'".$_POST['sale_m']."',
'".$_POST['name2']."',
'".$_POST['name2_nik']."',
'".$_POST['job']."',
'".$_POST['name_married']."',
'".$_POST['name_married_nik']."',
'".$_POST['name_guarantee']."',
'".$_POST['name_guarantee_nik']."',
'".$_POST['date']."'
";
*/ $sql = "UPDATE copy SET
copy.Contactno = '".$_POST['Contactno']."',
copy.productno = '".$_POST['productno']."',
copy.name = '".$_POST['name']."',
copy.employee = '".$_POST['employee']."',
copy.gold = '".$_POST['gold']."',
copy.gold_w = '".$_POST['gold_w']."',
copy.elec = '".$_POST['elec']."',
copy.elec_b = '".$_POST['elec_b']."',
copy.elec_m = '".$_POST['elec_m']."',
copy.more = '".$_POST['more']."',
copy.sale = '".$_POST['sale']."',
copy.sale_f = '".$_POST['sale_f']."',
copy.sale_d = '".$_POST['sale_d']."',
copy.sale_d2 = '".$_POST['sale_d2']."',
copy.sale_d3 = '".$_POST['sale_d3']."',
copy.sale_p = '".$_POST['sale_p']."',
copy.sale_p2 = '".$_POST['sale_p2']."',
copy.sale_p3 = '".$_POST['sale_p3']."',
copy.sale_m = '".$_POST['sale_m']."',
copy.name2 = '".$_POST['name2']."',
copy.name2_nik = '".$_POST['name2_nik']."',
copy.job = '".$_POST['job']."',
copy.name_married = '".$_POST['name_married']."',
copy.name_married_nik = '".$_POST['name_married_nik']."',
copy.name_guarantee = '".$_POST['name_guarantee']."',
copy.name_guarantee_nik = '".$_POST['name_guarantee_nik']."',
copy.date = '".$_POST['date']."'
";
$query = mysql_query($sql);
mysql_close();
?>
<meta content="0;URL=../index.php?Page=Copy" http-equiv="refresh" />
<?php
exit();
}
?>
</head>
<body>
</body>
</html>
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2012-02-09 09:44:18 |
By :
speed |
View :
1013 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เยอะแท้
มี error อะไรแจ้งหรือเปล่าครับ
|
 |
 |
 |
 |
Date :
2012-02-09 10:08:09 |
By :
13eachz |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$query = mysql_query($sql) or die(mysql_error());
|
 |
 |
 |
 |
Date :
2012-02-09 15:41:06 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่มีครับ พอคลิกปุ่ม update ก็จะ รีเฟรชไปหน้าที่ระบุไว้ แต่ข้อมูลก็ยังเหมือนเดิม เหมือนตอนที่ยังไม่ได้แก้ไขเลยครับ
|
 |
 |
 |
 |
Date :
2012-02-09 22:15:57 |
By :
speedfaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขึ้น error ดังนี้ครับ
Duplicate entry 'C-001' for key 2
ต้องแก้ไขยังไงต่อครับ รบกวนชี้แนะด้วยครับ
|
 |
 |
 |
 |
Date :
2012-02-10 00:06:55 |
By :
speedfaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|