|
 |
|
ผมลองเอา code จากบทความไปลองทำดูครับ อย่างอืนทำได้หมดครับ แต่พอตรง edit แก้ไข้ทำไมไม่่ได้ครับ |
|
 |
|
|
 |
 |
|
เอา code หน้า update มา ดู ครับ
|
 |
 |
 |
 |
Date :
2014-10-17 09:08:55 |
By :
gaowteen |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอา code ใส่แท็ก php หน่อยครับ
|
 |
 |
 |
 |
Date :
2014-10-17 09:19:35 |
By :
apisitp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มีประมาณนี้ครับที่ผมทำ มี 3 ไฟล์ยร่ตนัล
phpMySQLEditRecordList.php
</head>
<body>
<?php
$objConnect = mysql_connect("localhost","root","9899") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM customer";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">customerID</div></th>
<th width="98"> <div align="center">name</div></th>
<th width="198"> <div align="center">email</div></th>
<th width="97"> <div align="center">countrycode</div></th>
<th width="59"> <div align="center">budget</div></th>
<th width="71"> <div align="center">used</div></th>
<th width="30"> <div align="center">edit</div></th>
</tr>
<?php
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center"><?php echo $objResult["customerID"];?></div></td>
<td><?php echo $objResult["name"];?></td>
<td><?php echo $objResult["email"];?></td>
<td><div align="center"><?php echo $objResult["countrycode"];?></div></td>
<td align="right"><?php echo $objResult["budget"];?></td>
<td align="right"><?php echo $objResult["used"];?></td>
<td align="center"><a href="phpMySQLEditRecordForm.php?CusID=<?php echo $objResult["customerID"];?>">Edit</a></td>
</tr>
<?php
}
?>
</table>
<p>
<?php
mysql_close($objConnect);
?>
</p>
<p> </p>
<p><a href="index.php">กลับหน้าที่แล้ว</a></p>
phpMySQLEditRecordForm.php
<body>
<form action="phpMySQLEditRecordSave.php?CusID=<?php echo $_GET["CusID"];?>" name="frmEdit" method="post">
<?php
$objConnect = mysql_connect("localhost","root","9899") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM customer WHERE customerID = '".$_GET["CusID"]."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if(!$objResult)
{
echo "Not found CustomerID=".$_GET["CusID"];
}
else
{
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">customerID </div></th>
<th width="160"> <div align="center">name </div></th>
<th width="198"> <div align="center">email </div></th>
<th width="97"> <div align="center">countrycode </div></th>
<th width="70"> <div align="center">budget </div></th>
<th width="70"> <div align="center">used </div></th>
</tr>
<tr>
<td><div align="center"><input type="text" name="txtcustomerID" size="5" value="<?php echo $objResult["customerID"];?>"></div></td>
<td><input type="text" name="txtName" size="20" value="<?php echo $objResult["name"];?>"></td>
<td><input type="text" name="txtEmail" size="20" value="<?php echo $objResult["email"];?>"></td>
<td><div align="center"><input type="text" name="txtCountryCode" size="2" value="<?php echo $objResult["countryCode"];?>"></div></td>
<td align="right"><input type="text" name="txtBudget" size="5" value="<?php echo $objResult["budget"];?>"></td>
<td align="right"><input type="text" name="txtUsed" size="5" value="<?php echo $objResult["used"];?>"></td>
</tr>
</table>
<input type="submit" name="submit" value="submit">
<?php
}
mysql_close($objConnect);
?>
</form>
phpMySQLEditRecordSave.php
<body>
<p>
<?php
$objConnect = mysql_connect("localhost","root","9899") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "UPDATE customer SET ";
$strSQL .="customerID = '".$_POST["txtcustomerID"]."' ";
$strSQL .=",name = '".$_POST["txtname"]."' ";
$strSQL .=",email = '".$_POST["txtemail"]."' ";
$strSQL .=",countrycode = '".$_POST["txtcountryCode"]."' ";
$strSQL .=",budget = '".$_POST["txtbudget"]."' ";
$strSQL .=",used = '".$_POST["txtused"]."' ";
$strSQL .="WHERE customerID = '".$_GET["cusID"]."' ";
$objQuery = mysql_query($strSQL);
if($objQuery)
{
echo "Save Done.";
}
else
{
echo "Error Save [".$strSQL."]";
}
mysql_close($objConnect);
?>
</p>
<p><a href="index.php">กลับหน้าที่แล้ว</a></p>
</body>
รบกวนที่น่ะครับผมสงสัยว่าติดตรงไหนน่ะครับ
|
 |
 |
 |
 |
Date :
2014-10-17 10:17:51 |
By :
khoson |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมยังหาตำแหน่งผิดไม่เจอเลยครับจะแก้อย่างไหรดีครับ ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2014-10-17 11:51:22 |
By :
khoson |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลอง echo $strSQL ออกมาแล้ว copy ไป run ใน phpmyadmin ถ้ามัน error อะไรค่อยมันถามอีก ที
|
 |
 |
 |
 |
Date :
2014-10-17 11:56:26 |
By :
gaowteen |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ในไฟล์ เซฟ
$objQuery = mysql_query($strSQL) or die( mysql_error() . "\n<br>$strSQL") ;
|
ประวัติการแก้ไข 2014-10-17 12:02:49
 |
 |
 |
 |
Date :
2014-10-17 12:02:32 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|