修改HTML
<p style="text-align:center"><span style="font-size:24px">腦筋急轉彎-修改</span></p>
<form method="post" name="update">
<p>題目:<input name="q" required="required" type="text" value='<?php echo $row[xxxx]; ?>' /></p>
<p>答案:<input name="a" required="required" type="text" value='<?php echo $row[xxxx]; ?>' /></p>
<input name="tid" type="hidden" value="<?php echo $row[xxxx]; ?>" />
<p><input name="submit" type="submit" value="修改" /></p>
</form>
修改PHP
<?php
include("config.php");
header("Content-Type: text/html; charset=utf-8");
if($_POST['submit']) {
$sql_query = "update think set q='$_POST[xxxx]',a='$_POST[xxxx]' where tid='$_POST[xxxx]' ";
$db_link->query($sql_query) or die("錯誤:".$sql_query);
//echo $sql_query."<br>";
}
$sql_query = "SELECT * FROM think where tid = $_GET[xxxx] ";
$result = $db_link->query($sql_query);
$row = $result->fetch_array();
?>
刪除HTML
<td>動作</td>
<td><a href="list.php?tid=<?php echo $row[tid]; ?>">刪</a>、
<a href="update.php?tid=<?php echo $row[tid]; ?>">修</a>
</td>
刪除PHP
if($_GET[xxxx]) {
$sql_query = "delete from think where xxxx = $_GET[xxxx] ";
$db_link->query($sql_query) or die("錯誤:$sql_query");
}
刪除時的警告
onclick="javascript:return confirm('確定要刪除這筆資料嗎?');"