A. php 緊急求助,想實現點擊刪除按鈕刪除資料庫內對應的id信息
<?php
if(isset($_GET['id'])&&!empty($_GET['id'])){
$id=intval($_GET['id']);
$sql="delete from jxkc_a1 where id = $id";
if(mysql_query($sql)){
echo "<script type='text/javascript'>alert('操作成功')</script>";
}else{
echo "<script type='text/javascript'>alert('操作失敗')</script>";
}
}
?>
<?php
$arr = mysql_query("select * from jxkc_a1 where username='$username' order by id desc" );
while($result = mysql_fetch_array($arr))
{?>
<tr>
<td><span class="STYLE9"> <?php echo $result["lesson"];?> </td>
<td><span class="STYLE9"> <?php echo $result["plantime"];?> </td>
<td><span class="STYLE9"> <?php echo $result["student"];?> </td>
<td><span class="STYLE9"> <?php echo $result["classtime"];?> </td>
<td><span class="STYLE9"> <?php echo $result["type"];?> </td>
<td><a href=(這里假設你的地址是./list.php)"./list.php?id=<?php echo $result["id"] ?>" onclick=".......js">刪除</a></td>
</tr><?php } ?>