|
|
|
Edit ข้อมูลไม่ดึงมาแก้ Update ก็ไม่ได้อ่ะค่ะ ช่วยหน่อยนะ ข้อร้อง |
|
|
|
|
|
|
|
show.php
<html>
<body background="file:///C|/AppServ/www/tgi/image/11.jpg">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620" />
</head>
<title>แสดงข้อมูลลูกค้า</title>
<?php
include("style.html");
include("connect.php");
$sql = "select * from customer";
$qry = mysql_query($sql)or die (mysql_error());
echo "<table align=center border=1 bgcolor='#99CCFF' width='80%'>";
echo "<tr><td colspan=8 bgcolor='#0033CC'><br><center><b><font color='#FFFFFF'>รายละเอียดข้อมูลลูกค้า</b></font></center><br><td></tr>";
echo "<tr>";
echo "<th align=center width='15%'>เลขประจำตัวผู้เสียภาษี</th>";
echo "<th align=center width='15%'>ชื่อลูกค้า</th>";
echo "<th align=center width='17%'>ชื่อสถานประกอบการ</th>";
echo "<th align=center width='30%'>ที่อยู่สถานประกอบการ</th>";
echo "<th align=center width='12%'>เบอร์โทรศัพท์</th>";
echo "<th align=center width='11%'>เบอร์แฟกซ์</th>";
echo "<td colspan='2' align=center><a href='insertCusA.php'>เพิ่มข้อมูล</a></td>";
echo "</tr>";
while( $rs= mysql_fetch_array ($qry))
{
$id=$rs[0];
$name=$rs[1];
$comName=$rs[2];
$address=$rs[3];
$phone=$rs[4];
$fax=$rs[5];
echo "<tr>";
echo "<td align=center>$id</td>";
echo "<td align=center>$name</td>";
echo "<td align=center>$comName</td>";
echo "<td>$address</td>";
echo "<td align=center>$phone</td>";
echo "<td align=center>$fax</td>";
echo "<td align=center><a href='editCusA.php?id=$rs[0]'><IMG SRC='image/Btn_edit.gif' WIDTH='17' HEIGHT='16' BORDER='0' ALT='แก้ไข'></a></td>";
echo "<td align=center><a href='confirmCusA.php?id=$rs[0]'><IMG SRC='image/Icon_delete.gif' WIDTH='17' HEIGHT='16' BORDER='0' ALT='ลบ'></a></td>";
echo "</tr>";
}
echo "<tr><td colspan=8 bgcolor='#0033CC'><br><center><a href='selectTable.html'><b><font color='#FFFFFF'>[กลับไปเลือกรายการ] </font></a></center><br></td></tr>";
echo "</table>";
?>
</html>
edit.php
<title>แก้ไขข้อมูลลูกค้า</title>
<?php
include("style.html");
include("connect.php");
$id = $_GET[id];
$sql = "select * from customer where taxID=$id";
$query = mysql_query($sql) or die(mysql_error());
$rs = mysql_fetch_array($query);
$id=$rs[0];
$name = $rs[1];
$comName= $rs[2];
$address=$rs[3];
$phone= $rs[4];
$fax= $rs[5];
echo "<form method='post' action='updateCusA.php'>";
echo "<table align=center border=1 bgcolor='#99CCFF'>";
echo "<tr><td colspan=2 bgcolor='#0033CC'><br><center><b><font color='#FFFFFF'>แก้ไขข้อมูลลูกค้า</b></font></center><br><td></tr>";
echo "<tr>";
echo "<td>รหัสประจำตัวผู้เสียภาษี</td>";
echo "<td><input type=text size=50 name='taxID' value='$id'></td>";
echo "</tr>";
echo "<tr>";
echo "<td>ชื่อลูกค้า</td>";
echo "<td><input type='text' size=50 name='txtName' value='$name'></td>";
echo "</tr>";
echo "<tr>";
echo "<td>ชื่อสถานประกอบการ</td>";
echo "<td><input type=text size=50 name='txtcomName' value='$comName'></td>";
echo "</tr>";
echo "<tr>";
echo "<td>ที่อยู่</td>";
echo "<td><textarea name='txaAddress' value='$address' rows='10' cols='50'>".$address;
echo "</textarea>";
echo "</tr>";
echo "<tr>";
echo "<td>เบอร์โทรศัพท์</td>";
echo "<td><input type='text' name='txtPhone' value='$phone'>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>เบอร์แฟกซ์</td>";
echo "<td><input type='text' name='txtFax' value='$fax'>";
echo "</td>";
echo "</tr>";
echo "<tr><td colspan=2 bgcolor='#0033CC'><br><center><input type=submit value=บันทึก><input type=button value=ยกเลิก onclick=\"location.href='showCusA.php'\"></center><br></td></tr>";
echo "<input type=hidden name=oldID value=$id>";
echo "</table>";
echo"<center>";
if($_GET[update] == "empty")
echo "<FONT COLOR='#33FF66'><b> กรุณากรอกข้อมูลให้ครบ</FONT> ";
echo"</center> ";
echo"<center>";
if($_GET[summ] == "sum")
echo "<FONT COLOR='#33FF66'><b> รหัสซ้ำ กรุณากรอกข้อมูลใหม่</FONT> ";
echo"</center> ";
echo "</form>";
?>
update.php
<title>แก้ไขข้อมูลลูกค้า</title>
<?php
include("connect.php");
$id = $_POST[taxID];
$name=$_POST[txtName];
$comName = $_POST[txtcomName];
$address=$_POST[txaAddress];
$phone=$_POST[txtPhone];
$fax=$_POST[txtFax];
$oldID = $_POST[oldID];
if( $id=="" || $name=="" || $comName=="" || $address=="" || $phone=="" || $fax=="" )
{
echo "<META HTTP-EQUIV='Refresh' CONTENT='0;URL=editCusA.php?update=empty'>";
}
else
{
//รหัสซ้ำ
//if($id!=$oldID)
//{
// $sql = "select * from customer where cusID=$id";
//$qry = mysql_query($sql) or die(mysql_error());
// if(mysql_num_rows($qry)>0)
// {
// echo "<META HTTP-EQUIV='Refresh' CONTENT='0;URL=editCusA.php?summ=sum'>";
// }
// else
// {
// $sql = "update customer set cusID=$id, name='$name', comName='$comName', address='$address', phone='$phone' ,fax='$fax' where cusID=$oldID";
// $qry = mysql_query($sql) or die(mysql_error());
// echo "<META HTTP-EQUIV='Refresh' CONTENT='0;URL=showCusA.php'>";
// }
//}
if($id==$oldID)
{
//กรณีไม่มีการเปลี่ยนแปลงค่า ID
$sql = "update customer set taxID='$id', name='$name', comName='$comName', address='$address', phone='$phone' ,fax='$fax' where taxID=$oldID";
$qry = mysql_query($sql) or die(mysql_error());
echo "<META HTTP-EQUIV='Refresh' CONTENT='0;URL=showCusA.php'>";
}
}
?>
Tag : - - - -
|
|
|
|
|
|
Date :
2010-04-30 15:14:19 |
By :
nook |
View :
1869 |
Reply :
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
บรรทัดที่ 45 : editCusA.php = edit.php
บรรทัดที่ 76 : updateCusA.php = update.php
|
|
|
|
|
Date :
2010-04-30 15:45:39 |
By :
onizike |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มันถูกแล้วค่ะ
edit.php แค่จะบอกว่ามันเป็นหน้า edit ค่ะ
update ก็เหมือนกัน
ใครพอรู้ช่วยหน่อยนะคะ
|
|
|
|
|
Date :
2010-04-30 16:00:23 |
By :
nook |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP) ลองดูแล้วกันน่ะครับ
show.php
<html>
<body background="file:///C|/AppServ/www/tgi/image/11.jpg">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620" />
</head>
<title>แสดงข้อมูลลูกค้า</title>
<?php
include("style.html");
include("connect.php");
$sql = "select * from customer";
$qry = mysql_query($sql)or die (mysql_error());
echo "<table align=center border=1 bgcolor='#99CCFF' width='80%'>";
echo "<tr><td colspan=8 bgcolor='#0033CC'><br><center><b><font color='#FFFFFF'>รายละเอียดข้อมูลลูกค้า</b></font></center><br><td></tr>";
echo "<tr>";
echo "<th align=center width='15%'>เลขประจำตัวผู้เสียภาษี</th>";
echo "<th align=center width='15%'>ชื่อลูกค้า</th>";
echo "<th align=center width='17%'>ชื่อสถานประกอบการ</th>";
echo "<th align=center width='30%'>ที่อยู่สถานประกอบการ</th>";
echo "<th align=center width='12%'>เบอร์โทรศัพท์</th>";
echo "<th align=center width='11%'>เบอร์แฟกซ์</th>";
echo "<td colspan='2' align=center><a href='insertCusA.php'>เพิ่มข้อมูล</a></td>";
echo "</tr>";
while( $rs= mysql_fetch_array ($qry))
{
$id=$rs[0];
$name=$rs[1];
$comName=$rs[2];
$address=$rs[3];
$phone=$rs[4];
$fax=$rs[5];
echo "<tr>";
echo "<td align=center>$id</td>";
echo "<td align=center>$name</td>";
echo "<td align=center>$comName</td>";
echo "<td>$address</td>";
echo "<td align=center>$phone</td>";
echo "<td align=center>$fax</td>";
echo "<td align=center><a href='editCusA.php?id=<?=$id?><IMG SRC='image/Btn_edit.gif' WIDTH='17' HEIGHT='16' BORDER='0' ALT='แก้ไข'></a></td>";
echo "<td align=center><a href='confirmCusA.php?id=<?=$id?><IMG SRC='image/Icon_delete.gif' WIDTH='17' HEIGHT='16' BORDER='0' ALT='ลบ'></a></td>";
echo "</tr>";
}
echo "<tr><td colspan=8 bgcolor='#0033CC'><br><center><a href='selectTable.html'><b><font color='#FFFFFF'>[กลับไปเลือกรายการ] </font></a></center><br></td></tr>";
echo "</table>";
?>
</html>
edit.php
<title>แก้ไขข้อมูลลูกค้า</title>
<?php
include("style.html");
include("connect.php");
$id = $_GET[id];
$sql = "select * from customer where taxID=$id";
$query = mysql_query($sql) or die(mysql_error());
$rs = mysql_fetch_array($query);
$id=$rs[0];
$name = $rs[1];
$comName= $rs[2];
$address=$rs[3];
$phone= $rs[4];
$fax= $rs[5];
echo "<form method='post' action='updateCusA.php'>";
echo "<table align=center border=1 bgcolor='#99CCFF'>";
echo "<tr><td colspan=2 bgcolor='#0033CC'><br><center><b><font color='#FFFFFF'>แก้ไขข้อมูลลูกค้า</b></font></center><br><td></tr>";
echo "<tr>";
echo "<td>รหัสประจำตัวผู้เสียภาษี</td>";
echo "<td><input type=text size=50 name='taxID' value='$id'></td>";
echo "</tr>";
echo "<tr>";
echo "<td>ชื่อลูกค้า</td>";
echo "<td><input type='text' size=50 name='txtName' value='$name'></td>";
echo "</tr>";
echo "<tr>";
echo "<td>ชื่อสถานประกอบการ</td>";
echo "<td><input type=text size=50 name='txtcomName' value='$comName'></td>";
echo "</tr>";
echo "<tr>";
echo "<td>ที่อยู่</td>";
echo "<td><textarea name='txaAddress' value='$address' rows='10' cols='50'>".$address;
echo "</textarea>";
echo "</tr>";
echo "<tr>";
echo "<td>เบอร์โทรศัพท์</td>";
echo "<td><input type='text' name='txtPhone' value='$phone'>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>เบอร์แฟกซ์</td>";
echo "<td><input type='text' name='txtFax' value='$fax'>";
echo "</td>";
echo "</tr>";
echo "<tr><td colspan=2 bgcolor='#0033CC'><br><center><input type=submit value=บันทึก><input type=button value=ยกเลิก onclick=\"location.href='showCusA.php'\"></center><br></td></tr>";
echo "<input type=hidden name=oldID value=$id>";
echo "</table>";
echo"<center>";
if($_GET[update] == "empty")
echo "<FONT COLOR='#33FF66'><b> กรุณากรอกข้อมูลให้ครบ</FONT> ";
echo"</center> ";
echo"<center>";
if($_GET[summ] == "sum")
echo "<FONT COLOR='#33FF66'><b> รหัสซ้ำ กรุณากรอกข้อมูลใหม่</FONT> ";
echo"</center> ";
echo "</form>";
?>
update.php
<title>แก้ไขข้อมูลลูกค้า</title>
<?php
include("connect.php");
$id = $_POST[taxID];
$name=$_POST[txtName];
$comName = $_POST[txtcomName];
$address=$_POST[txaAddress];
$phone=$_POST[txtPhone];
$fax=$_POST[txtFax];
$oldID = $_POST[oldID];
if( $id=="" || $name=="" || $comName=="" || $address=="" || $phone=="" || $fax=="" )
{
echo "<META HTTP-EQUIV='Refresh' CONTENT='0;URL=editCusA.php?update=empty'>";
}
else
{
//รหัสซ้ำ
//if($id!=$oldID)
//{
// $sql = "select * from customer where cusID=$id";
//$qry = mysql_query($sql) or die(mysql_error());
// if(mysql_num_rows($qry)>0)
// {
// echo "<META HTTP-EQUIV='Refresh' CONTENT='0;URL=editCusA.php?summ=sum'>";
// }
// else
// {
// $sql = "update customer set cusID=$id, name='$name', comName='$comName', address='$address', phone='$phone' ,fax='$fax' where cusID=$oldID";
// $qry = mysql_query($sql) or die(mysql_error());
// echo "<META HTTP-EQUIV='Refresh' CONTENT='0;URL=showCusA.php'>";
// }
//}
if($id==$oldID)
{
//กรณีไม่มีการเปลี่ยนแปลงค่า ID
$sql = "update customer set taxID='$id', name='$name', comName='$comName', address='$address', phone='$phone' ,fax='$fax' where taxID=$oldID";
$qry = mysql_query($sql) or die(mysql_error());
echo "<META HTTP-EQUIV='Refresh' CONTENT='0;URL=showCusA.php'>";
}
}
?>
|
|
|
|
|
Date :
2010-04-30 16:56:35 |
By :
chonburi f.c |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
หมายความว่าหน้า edit แสดงข้อมูลไม่ได้หรือว่ายังไง
|
|
|
|
|
Date :
2010-04-30 17:10:02 |
By :
a |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|