|
 |
|
เเก้ข้อมูล record หลายๆ ฟิลด์ ที่มีหลาย record ทำไมอันเเรก save done ID อันหลัง ๆ เป็น error ครับ |
|
 |
|
|
 |
 |
|
จากตัวอย่าง https://www.thaicreate.com/php/php-mysql-update-edit-record.html
รอบบนี้ผมต้องการที่จะเเก้ ขอมูลใน record หลาย ๆ ตัว เช่น name, info, rate เเต่ไม่ต้องการเเก้ในส่วน id น่ะครับ
ผมได้ทดลองเขียน code อันนี้ คือตัวที่โชว record จะคล้าย ๆ กับ
https://www.thaicreate.com/upload/tutorial/php-mysql-edit-record2.jpg เพื่อให้เราเเก้ไขข้อมูลครับ
Code (PHP)
<?
echo $_GET['Record'];
require "../connect/connect.php";
$strSQL = "SELECT * FROM tbdb WHERE id = '".$_GET['id']."' ";
$objDB = mysql_select_db("mydb");
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if(!$objResult)
{
echo "Not found Record ID=".$_GET['id'];
}
else
{
?>
หลังจาก กดปุ่ม submit เเล้ว ถ้าเป็น ID0 ตัวเเรกมันเเก้ไขได้ เเต่ถ้าเป็น ID1, 2 , 3 record ตัวอื่น มันจะขึ้น error เเละโชวที่เเก้ออกมา
Code (PHP)
<?
require "../connect/connect.php";
$objDB = mysql_select_db("mydb");
$strSQL = "UPDATE tbdb SET ";
$strSQL .="id = '".$_POST["id"]."' ";
$strSQL .=",name = '".$_POST["name"]."' ";
$strSQL .=",img = '".$_POST["img"]."' ";
$strSQL .=",address = '".$_POST["address"]."' ";
$strSQL .=",area = '".$_POST["area"]."' ";
$strSQL .=",provinces = '".$_POST["provinces"]."' ";
$strSQL .=",info = '".$_POST["info"]."' ";
$strSQL .=",url = '".$_POST["url"]."' ";
$strSQL .="WHERE id = '".$_GET["id"]."' ";
$objQuery = mysql_query($strSQL);
if($objQuery)
{
echo "Save Done.";
}
else
{
echo "Error Save [".$strSQL."]";
}
mysql_close($objConnect);
?>
ผมงงครับ ว่าผมทำตัวไหนผิดไปอยู่
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2010-01-14 11:31:33 |
By :
designbyrod |
View :
1350 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
55 ได้เเล้วครับ พอไล่ดู
<?
require "../connect/connect.php";
$objDB = mysql_select_db("mydb");
$strSQL = "UPDATE tbdb SET ";
$strSQL .="id = '".$_POST["id"]."' ";
ตัวนี้ครับ มันต้องเเก้เป็น
$strSQL .="id = '".$_GET["id"]."' ";
ครับ อันนี้วิธีการของผมน่ะ มันผ่าน เเต่ เผื่อท่านอื่นมีวีธีการอื่น เเนะนำได้ครับ
ผมไม่เก่ง php เท่าไหร่ ยินดีน้อมรับ
|
 |
 |
 |
 |
Date :
2010-01-14 12:02:04 |
By :
designbyrod |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|