0
更新頁:問題在使用PHP更新表
<?php
mysql_connect("localhost","root","");//database connection
mysql_select_db("basic");
$data_id = $_GET['id'];
$order = "select * from user where id=$data_id"; $result=mysql_query($order);
while($row = mysql_fetch_array($result))
{
$fn= $row['First_name'] ; $ln= $row['last_name'] ; $s= $row['sex'] ; $ad= $row['address']; }
?> <form action="form_finalupdate.php" method="GET" >
<fieldset> <legend>Welcome <?php echo "$fn" ?></legend>
Update your Information:<br><br>
First Name: <input type="text" name="fname" value="<?php echo "$fn"
?>" > Last Name: <input type="text" name ="lname"
value="<?php echo "$ln" ?>" > <br><br>
Sex:<br> <input type="radio" name="sex" value="male" value="<?php echo
"$s"?>" >Male<br> <input type="radio" name="sex" value="female"
value="<?php echo "$s" ?>" >Female<br><br>
Address: <input type=text name="add"value="<?php echo "$ad" ?>" >
<br><br>
<input type="submit" value="Update" >
</fieldset> </form>
Finalupdate頁:
<?php
mysql_connect("localhost","root","");//database connection
mysql_select_db("basic");
$data_id = $_GET['id'];
$fn= $row['First_name'] ; $ln= $row['last_name'] ; $s= $row['sex'] ; $ad= $row['address'];
$order = "UPDATE user
SET First_name='$fn',last_name='$ln',sex='$s',address='$ad'
WHERE id='$data_id' ";
$result=mysql_query($order); ?>
問題是? – Drew
其實我試圖更新數據庫表,並顯示值恢復正常形式。但它給最終update.php文件中的錯誤說未定義的變量:在C:\ xampp \ htdocs \ dip \ form_finalupdate.php在第8行等行...請幫我 –
爲什麼他會使用set不止一次@SunilPachlangia? – Drew