|
 |
|
Edit แล้วอัพเดทข้อมูลไม่ได้ครับ จนปัญญาแล้วครับช่วยทีครับผม (PHP+MySQL) |
|
 |
|
|
 |
 |
|
Code หน้า Edit ครับ
Code (PHP)
<form action="EditSave.php?PES_ID=<?=$_GET["PES_ID"];?>" name="frmEdit" method="post">
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("Projectfinal");
$strSQL = "SELECT * FROM PES WHERE PES_ID = '".$_GET["PES_ID"]."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if(!$objResult)
{
echo "Not found PES_ID=".$_GET["PES_ID"];
}
else
{
?>
<table width="764" border="1">
<tr>
<th width="78"> <div align="center">Name </div></th>
<th width="140"> <div align="center">Lastname </div></th>
<th width="95">ValueMarket</th>
<th width="95">Contract</th>
<th width="95">Match</th>
<th width="95"> <div align="center">Goal </div></th>
<th width="56"> <div align="center">Assist </div></th>
<th width="58"> <div align="center">Salary </div></th>
</tr>
<tr>
<td><div align="center"><input name="PES_Name" type="text" id="PES_Name" value="<?=$objResult["PES_Name"];?>" size="5"></div></td>
<td><input name="PES_Lastname" type="text" id="PES_Lastname" value="<?=$objResult["PES_Lastname"];?>" size="5"></td>
<td><input name="ValueMarket" type="text" id="PES_Contract" value="<?=$objResult["ValueMarket"];?>" size="5"></td>
<td><div align="center"><input name="PES_Contract" type="text" id="PES_Contract" value="<?=$objResult["PES_Contract"];?>" size="5"></div></td>
<td align="right"><input name="Match" type="text" id="Match" value="<?=$objResult["Macth"];?>" size="5"></td>
<td align="right"><input name="Goal" type="text" id="Goal" value="<?=$objResult["Goal"];?>" size="5"></td>
<td align="right"><input name="Assist" type="text" id="Assist" value="<?=$objResult["Assist"];?>" size="5"></td>
<td align="right"><input name="PES_Salary" type="text" id="PES_Salary" value="<?=$objResult["PES_Salary"];?>" size="5"></td>
</tr>
</table>
<input type="submit" name="submit" value="submit">
<?
}
mysql_close($objConnect);
?>
</form>
Code หน้า Save (Update) ครับ
Code (PHP)
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("projectfinal");
$strSQL = "UPDATE PES SET ";
$strSQL .="PES_Name = '".$_POST["PES_Name"]."' ";
$strSQL .=",PES_Lastname= '".$_POST["PES_Lastname"]."' ";
$strSQL .=",ValueMarket = '".$_POST["ValueMarket"]."' ";
$strSQL .=",PES_Contract = '".$_POST["PES_Contract"]."' ";
$strSQL .=",Match = '".$_POST["Match"]."' ";
$strSQL .=",Goal = '".$_POST["Goal"]."' ";
$strSQL .=",Assist = '".$_POST["Assist"]."' ";
$strSQL .=",PES_Salary = '".$_POST["PES_Salary"]."' ";
$strSQL .="WHERE PES_ID = '".$_GET["PES_ID"]."' ";
$objQuery = mysql_query($strSQL);
if($objQuery)
{
echo "Save Done.";
}
else
{
echo "Error Save [".$strSQL."]";
}
mysql_close($objConnect);
?>
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2012-06-04 22:50:03 |
By :
esprasiona |
View :
836 |
Reply :
6 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$objQuery = mysql_query($strSQL) or die(mysql_error());
เอา error มาดูครับ
|
 |
 |
 |
 |
Date :
2012-06-05 06:16:14 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แล้วถ้าเป็นชื่อตาราง Match ก็มีผลเหมือนกันหรือเปล่าครับเพราะ insert ข้อมูลลง Database "Match" ไม่ได้ครับ ถ้าใช่จะได้เปลี่ยนชื่อครับผท
Code (PHP)
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("projectfinal");
$strSQL = "INSERT INTO Match ";
$strSQL .="(M_ID,Date,Namelist,StartTime,Score,Visit,M_Report) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["M_ID"]."','".$_POST["Date"]."','".$_POST["Namelist"]."'";
$strSQL .=",'".$_POST["StartTime"]."','".$_POST["Score"]."','".$_POST["Visit"]."'";
$strSQL .=",'".$_POST["M_Report"]."' )";
$objQuery = mysql_query($strSQL);
if($objQuery)
{
echo "Save Done.";
}
else
{
echo "Error Save [".$strSQL."]";
}
mysql_close($objConnect);
?>
|
 |
 |
 |
 |
Date :
2012-06-05 09:04:47 |
By :
esprasiona |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มีครับ แนะนำให้เปลี่ยนชื่อครับ จะมีผลดีในระยะยาวครับ 
|
 |
 |
 |
 |
Date :
2012-06-05 09:11:18 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากครับพี่ 
ได้พี่ช่วยไว้เยอะจริง ๆ
|
 |
 |
 |
 |
Date :
2012-06-05 09:20:29 |
By :
esprasiona |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|