|
|
|
ทำหน้าแก้ไขครับเวลา กดแก้ไขแล้วให้ข้อมูลที่แก้ไขยังแสดงอยู่ต้องทำยังไงหรือครับ |
|
|
|
|
|
|
|
ทำหน้าแก้ไขครับเวลา กดแก้ไขแล้วให้ข้อมูลที่แก้ไขยังแสดงอยู่ ต้องทำยังไงหรือครับ ต้องแก้ไขตรงใหนมั่งหรือครับ
form1.php
<?php
@session_start();
?>
<?php
include('connect.php');
$sql = "SELECT CustID FROM tbcustomer WHERE CustID = $CustID";
$query = mysql_db_query($dbname, $sql) or die("Can't Query1");
$cus_id = mysql_fetch_array($query);
$id1 = $cus_id[0];
$sql = "SELECT Company FROM tbcustomer WHERE CustID = $CustID";
$query = mysql_db_query($dbname, $sql) or die("Can't Query");
$cus_id = mysql_fetch_array($query);
$id2 = $cus_id[0];
$sql = "SELECT Credit FROM tbcustomer WHERE CustID = $CustID";
$query = mysql_db_query($dbname, $sql) or die("Can't Query");
$cus_id = mysql_fetch_array($query);
$id3 = $cus_id[0];
$sql = "SELECT CurAdd1 FROM tbcustomer WHERE CustID = $CustID";
$query = mysql_db_query($dbname, $sql) or die("Can't Query");
$cus_id = mysql_fetch_array($query);
$id4 = $cus_id[0];
$sql = "SELECT ContactPerson1 FROM tbcustomer WHERE CustID = $CustID";
$query = mysql_db_query($dbname, $sql) or die("Can't Query");
$cus_id = mysql_fetch_array($query);
$id5 = $cus_id[0];
$sql = "SELECT ContactPosition1 FROM tbcustomer WHERE CustID = $CustID";
$query = mysql_db_query($dbname, $sql) or die("Can't Query");
$cus_id = mysql_fetch_array($query);
$id6 = $cus_id[0];
$sql = "SELECT Tel FROM tbcustomer WHERE CustID = $CustID";
$query = mysql_db_query($dbname, $sql) or die("Can't Query");
$cus_id = mysql_fetch_array($query);
$id7 = $cus_id[0];
$sql = "SELECT Fax FROM tbcustomer WHERE CustID = $CustID";
$query = mysql_db_query($dbname, $sql) or die("Can't Query");
$cus_id = mysql_fetch_array($query);
$id8 = $cus_id[0];
$sql = "SELECT Email FROM tbcustomer WHERE CustID = $CustID";
$query = mysql_db_query($dbname, $sql) or die("Can't Query");
$cus_id = mysql_fetch_array($query);
$id9 = $cus_id[0];
$sql = "SELECT Website FROM tbcustomer WHERE CustID = $CustID";
$query = mysql_db_query($dbname, $sql) or die("Can't Query");
$cus_id = mysql_fetch_array($query);
$id10 = $cus_id[0];
$sql = "SELECT Remark FROM tbcustomer WHERE CustID = $CustID";
$query = mysql_db_query($dbname, $sql) or die("Can't Query");
$cus_id = mysql_fetch_array($query);
$id11 = $cus_id[0];
$sql = "SELECT Active FROM tbcustomer WHERE CustID = $CustID";
$query = mysql_db_query($dbname, $sql) or die("Can't Query");
$cus_id = mysql_fetch_array($query);
$id12 = $cus_id[0];
?>
</table>
<!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>ข้อมูลลูกค้า</title>
<script type="text/javascript">
function onAdd(){
window.location='formB1_editcode.php';
}
function onCancle(){
window.location='formB1.php';
}
function onBack(){
window.location='menu_formB.php';
}
function fncSubmit(){
if(confirm('ต้องการจะลบจริงหรือไม่ ?') == true){
return true;
}
else
{
return false;
}
}
function fncSubmit1(){
if(confirm('ต้องการจะแก้ไขจริงหรือไม่ ?') == true){
return true;
}
else
{
return false;
}
}
</script>
<style type="text/css">
<!--
.style1 {color: #FFFF00}
.style3 {font-size: 18px}
-->
</style>
</head>
<body>
<form name="form1" method="post" action="formB1_edit_code.php">
<table width="1024" height="650" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#0000FF">
<!--DWLayoutTable-->
<tr>
<td valign="top"><img src="images/banner.png" width="100%" height="100" /></td>
</tr>
<tr>
<td valign="top"><table width="100%" height="20" border="0" bordercolor="#0000FF">
<tr>
<td><div align="right">[ ชื่อผู้เข้าใช้ : <?php echo $_SESSION['user_login']; ?> ] [ วัน : <?php echo date("d/m/y", time()); ?> ] [ เวลา : <?php echo date("H:i:s", time()); ?> ]</div></td>
</tr>
</table>
<table width="100%" height="500" border="1" bordercolor="#0000FF">
<tr>
<td height="213" valign="top"><div align="center">
<div align="center">
<table width="446" border="0">
<tr>
<td><div align="center" class="style3">ข้อมูลลูกค้า</div></td>
</tr>
</table>
<table width="100%" border="1" align="center" bordercolor="#0099FF" bgcolor="#CCFFFF">
<tr>
<td width="128"><div align="right">รหัสลูกค้า :</div></td>
<td width="153"><div align="left">
<label>
<input name="txtCode" type="text" size="20" readonly="readonly" value="<? echo $id1; ?>"/>
</label>
</div></td>
<td colspan="3"><div align="right">วันที่ปรับปรุง :</div></td>
<td width="267"><div align="left">
<?php echo date("d/m/y", time()); ?></div></td>
</tr>
<tr>
<td><div align="right">ชื่อลูกค้า :</div></td>
<td colspan="5"><div align="left">
<label>
<input name="txtName" type="text" size="100" value="<? echo $id2; ?>"/>
</label>
</div></td>
</tr>
<tr>
<td><div align="right">ที่อยู่ :</div></td>
<td colspan="5"><div align="left">
<label>
<input name="txtAddress" type="text" size="100" value="<? echo $id4; ?>"/>
</label>
</div></td>
</tr>
<tr>
<td><div align="right">โทรศัพท์ :</div></td>
<td><div align="left">
<label>
<input type="text" name="txtPhone" value="<? echo $id7; ?>"/>
</label>
</div></td>
<td><div align="right">โทรสาร :</div></td>
<td width="167"><div align="left">
<label>
<input type="text" name="txtFax"value="<? echo $id8; ?>" />
</label>
</div></td>
<td width="142"><div align="right">Email :</div></td>
<td><div align="left">
<label>
<input type="text" name="txtEmail" value="<? echo $id9; ?>"/>
</label>
</div></td>
</tr>
<tr>
<td><div align="right">Website :</div></td>
<td colspan="3"><div align="left">
<label>
<input name="txtWeb" type="text" size="72" value="<? echo $id10; ?>"/>
</label>
</div>
<label></label></td>
<td><div align="right">บุคคลที่ติดต่อ :</div></td>
<td><div align="left">
<label>
<input type="text" name="txtConnect" value="<? echo $id5; ?>"/>
</label>
</div></td>
</tr>
<tr>
<td><div align="right">ตำแหน่ง :</div></td>
<td><div align="left">
<label>
<input type="text" name="txtPosition"value="<? echo $id6; ?>"/>
</label>
</div>
<label></label></td>
<td width="121"><div align="right">ปล่อยเครดิต :</div></td>
<td colspan="3"><label></label>
<div align="left">
<label>
<input type="text" name="txtCredit"value="<? echo $id10; ?>" />
</label>
วัน </div></td>
</tr>
<tr>
<td><div align="right">หมายเหตุ :</div></td>
<td colspan="5"><div align="left">
<label>
<input name="txtComment" type="text" size="100" value="<? echo $id11; ?>"/>
</label>
<label></label>
</div></td>
</tr>
<tr>
<td colspan="6"><label>
<div align="right">
<input type="checkbox" name="checkbox" value="<? echo $id12; ?>"/>
เลิกติดต่อแล้ว </div>
</label></td>
</tr>
<tr>
<td colspan="6"><table width="206" border="0" align="center">
<tr>
<td width="53"><div align="center">
<label>
<input input type="submit" name="btnSubmit" value="ตกลง" style="width:100px"/>
</label>
</div></td>
</form>
<td width="42"><div align="center">
<label>
<input type="button" name="btnBack" value="กลับหน้าข้อมูล" style="width:100px" onclick="JavaScript:onBack();"/>
</label>
</div></td>
</tr>
</table></td>
</tr>
</table>
<?
$sql = "SELECT CustID, Company FROM tbcustomer WHERE Status = 'T' AND Active = 'A'";
$query = mysql_db_query($dbname, $sql) or die("Can't Query1");
?>
<table width="1100" border="1">
<tr>
<th width="100"> <div align="center">Number </div></th>
<th width="100"> <div align="center">Company </div></th>
<th width="100"> <div align="center">แก้ไข </div></th>
<th width="100"> <div align="center">ลบ </div></th>
</tr>
<?
$num = 1;
while($CustID = mysql_fetch_array($query))
{
?>
<tr>
<td><div align="center"><?=$num;?></div></td>
<td><div align="center"><?=$CustID["Company"];?></div></td>
<td align="center"><a href="c"onClick='return fncSubmit1()'>แก้ไข</a></td>
<td align="center"><a href="formB1_delect.php?CustID=<?=$CustID["CustID"];?>"onClick='return fncSubmit()'>ลบ</a></td>
</tr>
</form>
</tr>
<?
$num++;}
?>
</div>
</div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="20" valign="top" bgcolor="#3366CC"><div align="center" class="style1">บริษัท เอ.ที. พริ้นติ้ง จำกัด </div></td>
</tr>
</table>
</body>
</html>
code.php
<?
include('connect.php');
include('formB1.php');
$id = $_POST["txtCode"];
//$LastUpdate = $_POST["txtDate"];
$Company = $_POST["txtName"];
$CurAdd1 = $_POST["txtAddress"];
$Tel = $_POST["txtPhone"];
$Fax = $_POST["txtFax"];
$Email = $_POST["txtEmail"];
$Website = $_POST["txtWeb"];
$ContactPerson1 = $_POST["txtConnect"];
$ContactPosition1 = $_POST["txtPosition"];
$Credit = $_POST["txtCredit"];
$Remark = $_POST["txtComment"];
$Active = $_POST["checkbox"];
if($_POST["checkbox"] != "")
{
$Active = "I";
}
else
{
$Active = "A";
}
// $sql = "SELECT MAX(CustID) FROM tbcustomer";
// $query = mysql_db_query($dbname, $sql) or die("Can't Query");
// $cus_id = mysql_fetch_array($query);
// $id = $cus_id[0] + 1 ;
$sql= " UPDATE tbcustomer SET Company = '$Company', Credit = '$Credit', CurAdd1 = '$CurAdd1', ContactPerson1 = '$ContactPerson1', ContactPosition1 = '$ContactPosition1', Tel = '$Tel', Fax = '$Fax', Email = '$Email', Website = '$Website', Remark = '$Remark',LastUpdate = now()
, Active = '$Active' WHERE CustID = '$id' ";
$query = mysql_db_query($dbname, $sql) or die("Can't Query");
if($query)
{
echo " <script language='javascript'>
alert('Update Success');
window.location='formB1_edit.php';
</script>
";
}else
{
echo " <script language='javascript'>
alert('Fail');
window.location='fromB1.php';
</script>
";
}
mysql_close();
?>
Tag : PHP
|
|
|
|
|
|
Date :
2011-09-14 19:56:50 |
By :
tangsupap |
View :
600 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอนนี้ ข้อมูลไปเก็บ ในฐานข้อมูลยังครับ
|
|
|
|
|
Date :
2011-09-14 20:48:38 |
By :
tormam |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ก็ละครับผม
|
|
|
|
|
Date :
2011-09-14 21:03:32 |
By :
tangsupap |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เวลา กดตกลงให้ข้อมูลที่ พึ่งแก้ไขไปยังคงอยู่ที่เดิม ครับ
|
|
|
|
|
Date :
2011-09-15 12:56:26 |
By :
tangsupap |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|