4
我是PHP新手,我試圖在單擊刪除按鈕時執行刪除查詢。目前if語句沒有被觸發,那麼我怎樣才能觸發按鈕中的if語句,以及如何獲取被點擊的按鈕的id?<button>點擊執行mysql查詢
<?
while($row = mysqli_fetch_array($result)) {
echo "<td>" . $row["id"] . "</td>";
echo "<td>" . $row["teamName"] . "</td>";
echo "<td>" . $row["name"] . "</td>";
echo "<td>" . $row["country"] . "</td>";
echo "<td>" . $row["birthday"] . "</td>";
echo "<td><button type='button' class='btn btn-default ' aria-label='Left Align'>Edit</button> ";
echo "<button type='button' class='btn btn btn-danger' aria-label='Left Align' name='remove' value='remove'>Remove</button></td>";
}
?>
if(isset($_POST['remove'])){
$removeQuery = "UPDATE Players Where id='ID PRESSED?'";
header('Location: '.$_SERVER['REQUEST_URI']);
}
旋轉按鈕與$ _GET變量的鏈接獲得ID,** delete.php?ID = **然後抓住id的刪除並將其設置爲查詢中的id。 @Peter – xtrman 2014-12-06 20:14:23