|
 |
|
(php)ดึงข้อมูลมาแก้ไขแล้วประโยคมันขาด มาแค่คำหน้า ช่วยเขียนโค้ด php หน่อยนะคะมีปัญหาโปรแกรมอ่ะค่ะ |
|
 |
|
|
 |
 |
|
ช่วยเขียนโค้ด php หน่อยนะคะ
มีปัญหาโปรแกรมอ่ะค่ะ
คือ
เวลาเราเพิ่มข้อมูลลงฐานข้อมูล(โดยมีข้อความที่เว้นวรรค เช่น หัว ก้อย) มันก็บรรทึกปกติ
ดึงมาโชว์ก็มาเต็มประโยค
แต่พอดึงมาแก้ไข มันมาแค่คำหน้าอ่ะค่ะ (มาแค่คำว่า"หัว") แล้วพอบันทึก มันก็บันทึกแค่คำวัน"หัว"
เพราะ update ล่าสุดตอนนั้นมันมีแต่คำว่าหัวอ่ะค่ะ
ทำไงให้มันดึงมาแก้ไขทั้งประโยคอ่ะคะ ช่วยหน่อยนะคะ
ขอบพระคุณอย่างสูง
โค้ดนะคะ
Edit.php
<title>แก้ไขข้อมูลลูกค้า</title>
<?php
include("style.html");
include("connect.php");
$id = $_GET[id];
$sql = "select * from customer where cusID=$id";
$query = mysql_query($sql) or die(mysql_error());
$rs = mysql_fetch_array($query);
$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=hidden size=50 name=txtID 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[txtID];
$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 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'>";
}
}
?>
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2010-04-23 14:53:30 |
By :
nook |
View :
1049 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
น่าจะเป็นที่ value=$name นะครับ
ควรจะครอบด้วย ' นะครับ
value='$name'
ทุก input เลยนะครับ
|
 |
 |
 |
 |
Date :
2010-04-23 15:16:22 |
By :
Rutz |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบพระคุณมากๆนะคะ   
|
 |
 |
 |
 |
Date :
2010-04-23 16:07:10 |
By :
nook |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมว่า โค้ดน่าจะประหยัด echo ได้เยอะเลยนะครับ
ถ้าอันไหนเป็น html แล้วให้มันมารวมใน echo เดี๋ยวกัน โดยใช้วิธี enter ในการจัดรูปแบบเอา
ไม่รู้ว่าผมคิดไปเองป่าวนะครับว่าถ้า echo น้อยน่าจะทำงานได้ดีกว่า
|
 |
 |
 |
 |
Date :
2010-04-23 16:42:18 |
By :
dekcomnvc |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|