1
我有這樣一段代碼:按鈕表使用PHP/SQL循環
<?php $res = $conn->query("SELECT * FROM users");
//If the result of the query has more than 0 rows (1 or more) continue to the loop
if(mysqli_num_rows($res) >0){
//Loop to organise the data
while($row = mysqli_fetch_array($res)){
if($row['permission'] == "2"){
$perms = '<span class="label label-danger">Administrator</span>';
} elseif($row['permission'] == "1"){
$perms = '<span class="label label-success">Registered User</span>';
} else {
$perms = '<span class="label label-warning">Awaiting Approval</span>';
}
//Return the table data
echo "<tr><td>" . $row['firstname'] . "</td><td>" . $row['surname'] . "</td><td>" . $row['email'] . "</td><td>" . $row['username'] . "</td><td>" . $row['telephone'] . "</td><td>" . $perms . "</td>";
}
}?>
我要的是在新列中添加一個按鈕,每一行,將激活一段代碼刪除記錄在數據庫中。
想知道如果有人可以幫助或點我就如何做到這一點的正確方向。最終會出現一個刪除按鈕和一個批准按鈕,用於激活位於同一文件中的不同SQL代碼。 謝謝
感謝您的回覆,我編輯了代碼以添加您建議的內容。但是,我無法點擊按鈕,它們顯示出來,但不允許我點擊它們來執行代碼。有任何想法嗎? –