20141222 作業十二 - 資料修改 se.php 20141222 作業十二 - 資料修改 se.php

<?php

$link=mysql_connect("localhost","root","123456") or die("無法連接資料庫");
 
mysql_select_db("school") or die("無法選擇資料庫");
 
mysql_query("SET NAMES 'utf8'");
 
$sql="select*from student where sid='$stid'";
 
$result = mysql_query($sql);
if(mysql_num_rows($result)==0){
echo "找無資料";
}
else{
$row=mysql_fetch_array($result);
echo "<form action=stupdate.php method=post name=myform>";
echo "<p>";
echo "學號:<input name=stid type=text value=$row[sid] readonly></p>";
echo "<p>";
echo "班級:<input name=stclass type=text value=$row[sclass]></p>";
echo "<p>";
echo "姓名:<input name=stname type=text value=$row[sname]></p>";
echo "<input name=key type=submit value=修改><input name=key type=reset value=重設></p>";
echo "</form>";
}
?>
 
20141222 作業十二 - 資料修改 index.html 20141222 作業十二 - 資料修改 index.html

<p>
 <form action="se.php" method="post" name="myform">
<p> 
 學號 : <input name="stid" type="text" /></p>
<p>
 <input name="key" type="submit" value="送出" /><input name="key" type="reset" value="重設" /></p>
</form>
<p>

20141222 作業十二 - 資料修改 stupdate.php 20141222 作業十二 - 資料修改 stupdate.php

 

<?php
$link=mysql_connect("localhost","root","123456") or die("無法連接資料庫");
 
mysql_select_db("school") or die("無法選擇資料庫");
 
mysql_query("SET NAMES 'utf8'");
 
$sql="update student set sclass='$stclass',sname='$stname' where sid='$stid'";
mysql_query($sql) or die("更新失敗");
header('Location: index.html');
?>
20141222 作業十二 - 資料修改結果 20141222 作業十二 - 資料修改結果