|
|
|
update ข้อมูลของ sql ไม่ได้ครับ คือ สั่งให้ update ได้แล้วแต่มันไม่ยอมเก็บค่าที่ update ใหม่เข้าไปจะแก้ยังไงดีครับ |
|
|
|
|
|
|
|
<!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>Untitled Document</title>
</head>
<?
// เชื่่อมต่อฐานข้อมูล
$host="localhost"; // กำหนด host
$username="root"; // กำหนด username
$pass_word="together"; // กำหนด Password
$db="project"; // กำหนดชื่อฐานข้อมูล
$Conn = mysql_connect( $host,$username,$pass_word) or die ("ติดต่อฐานข้อมูลไม่ได้");// ติดต่อฐานข้อมูล
mysql_query("SET NAMES utf8",$Conn); // set กำหนดมาตราฐาน
mysql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้"); // เลือกฐานข้อมูล
//--->
if($_POST['Edit'])
{
$id = $_REQUEST['edit_id'];
$FirstName = $_POST['FirstName'];
$LastName = $_POST['LastName'];
$Number_Match_In_National = $_POST['Number_Match_In_National'];
$Position_ = $_POST['Position_'];
$Birthday = $_POST['Birthday'];
$Goal_In_National = $_POST['Goal_In_National'];
$Goal_In_WorldCup_2010 = $_POST['Goal_In_WorldCup_2010'];
$National_Name = $_POST['National_Name'];
$NumberInNational = $_POST['NumberInNational'];
// แก้ไขข้อมูล
$sql_edit = "update player set
FirstName = '$FirstName' , LastName = '$LastName' , Number_Match_In_National = '$Number_Match_In_National' , Position_ = '$Position_' , Birthday = '$Birthday' , Goal_In_National = '$Goal_In_National' , Goal_In_WorldCup_2010 = '$Goal_In_WorldCup_2010' , National_Name = '$National_Name' , NumberInNational = '$NumberInNational' where id = '$id'";
mysql_query($sql_edit) or die(mysql_error());
echo "แก้ไขข้อมูลของ $FirstName สำเร็จแล้ว";
//-->
}
//เรียกข้อมูลจาก รหัส มาแสดงใน textbox
if($_REQUEST['edit_id'] != "")
{
$id = $_REQUEST['edit_id'];
$sql_show = "select * from player where id = '$id'";
$result_show = mysql_query($sql_show) or die(mysql_error());
$row_show = mysql_fetch_array($result_show);
}
//-->
?>
<body>
<form id="form1" name="form1" method="post" action="test.php">
<p>Player ID
<input type="text" name="id" id="id" value="<?=$row_show['id']?>" />
<br />
<br />
FirstName
<input type="text" name="FirstName" id="FirstName" value="<?=$row_show['FirstName']?>" />
<br />
<br />
LastName
<input type="text" name="LastName" id="LastName" value="<?=$row_show['LastName']?>" />
</p>
<p>
Match in National
<input type="text" name="Number_Match_In_National" id="Number_Match_In_National" value="<?=$row_show['Number_Match_In_National']?>" />
</p>
<p>
Position
<input type="text" name="Position_" id="Position_" value="<?=$row_show['Position_']?>" />
</p>
<p>
Birthday
<input type="text" name="Birthday" id="Birthday" value="<?=$row_show['Birthday']?>" />
</p>
<p>
Goal in National
<input type="text" name="Goal_In_National" id="Goal_In_National" value="<?=$row_show['Goal_In_National']?>" />
</p>
<p>
Goal in WC2010
<input type="text" name="Goal_In_WorldCup_2010" id="Goal_In_WorldCup_2010" value="<?=$row_show['Goal_In_WorldCup_2010']?>" />
</p>
<p>
National
<input type="text" name="National_Name" id="National_Name" value="<?=$row_show['National_Name']?>" />
</p>
<p>
Number in National
<input type="text" name="NumberInNational" id="NumberInNational" value="<?=$row_show['NumberInNational']?>" />
</p>
<p>
Football Club
<input type="text" name="FC" id="FC" value="<?=$row_show['FC']?>" />
</p>
<p>
<input type="submit" name="Edit" id="Edit" value="Edit" " />
</p>
<p>
<input name="edit_id" type="hidden" id="edit_id" value="<?=$_REQUEST['edit_id']?>" />
<a href="pojex2.php">ดูข้อมูลนักเตะ</a></p>
<p>
</form>
</html>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2010-10-14 03:00:55 |
By :
bagilisk |
View :
1121 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
echo $sql_edit;
ลองดูว่าค่าตรงไหนไม่ครบครับ
|
|
|
|
|
Date :
2010-10-14 06:29:45 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|