Итак, мой код ниже, который читается из dmgeqdelete.php, который мгновенно удалит данные из базы данных. <td align = "center">
<a href = "dmgeqdelete.php?damagedID=<?php echo $row["damagedID"]; ?>" >Delete</a>
</td>
Я пытаюсь добавить всплывающее подтверждение для кода выше. я пробовал <td align = "center">
<a href = "dmgeqdelete.php?damagedID=<?php echo $row["damagedID"]; ?>" onclick = "return confirm('Are you sure?')">Delete</a>
</td> ничего не происходит
dmgeqdelete.php
<?php
include('dbConfig.php');
$damagedID=$_REQUEST['damagedID'];
$query = "DELETE FROM damagedeq WHERE damagedID=$damagedID";
$result = mysqli_query($conn,$query) or die ( mysqli_error());
header("Location: dmgeqview.php");
?>полный код
<?php
include('dbConfig.php');
?>
<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<title>View Damaged Equipment Records</title>
<link rel = "stylesheet" href = "css/style.css" />
</head>
<body>
<div class = "form">
<p><a href = "report.php">Home</a> | <a href = "index.php">Logout</a></p>
<h2>View Records</h2>
<table width = "100%" border = "1" style = "border-collapse:collapse;">
<thead>
<tr>
<th><strong>No</strong></th>
<th><strong>Damage ID's</strong></th>
<th><strong>EQ ID's</strong></th>
<th><strong>Student ID's</strong></th>
<th><strong>Staff ID's</strong></th>
<th><strong>Date reported</strong></th>
<th><strong>Date repaired</strong></th>
<th><strong>Equipment Status</strong></th>
</tr>
</thead>
<tbody>
<?php
$count=1;
$sel_query = "Select * from damagedeq ORDER BY damagedID desc;";
$result = mysqli_query($conn,$sel_query);
while($row = mysqli_fetch_assoc($result)) { ?>
<tr>
<td align = "center">
<?php echo $count; ?>
</td>
<td align = "center">
<?php echo $row["damagedID"]; ?>
</td>
<td align = "center">
<?php echo $row["equipmentID"]; ?>
</td>
<td align = "center">
<?php echo $row["studentID"]; ?>
</td>
<td align = "center">
<?php echo $row["staffID"]; ?>
</td>
<td align = "center">
<?php echo $row["dateReported"]; ?>
</td>
<td align = "center">
<?php echo $row["dateRepaired"]; ?>
</td>
<td align = "center">
<?php echo $row["equipmentStatus"]; ?>
</td>
<td align = "center">
<a href = "dmgequp.php?damagedID=<?php echo $row[" damagedID "]; ?>">Edit</a>
</td>
<td align = "center">
<a href = "dmgeqdelete.php?damagedID=<?php echo $row[" damagedID "]; ?>">Delete</a>
</td>
</tr>
<?php $count++; } ?>
</tbody>
</table>
</div>
</body>
</html>


![Безумие обратных вызовов в javascript [JS]](https://i.imgur.com/WsjO6zJb.png)


Здесь нужно просто остановить дальнейшее выполнение кода
onclick = "return confirm('Are you sure?')"
добавление return false в конце вот так
onclick = "return confirm('Are you sure?'); return false;"
При нажатии на отменить ничего не произойдет, а если нажать на Ok то перейдет по ссылке
Вот полный фрагмент кода
<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<title>View Damaged Equipment Records</title>
<link rel = "stylesheet" href = "css/style.css" />
</head>
<body>
<div class = "form">
<p><a href = "report.php">Home</a> | <a href = "index.php">Logout</a></p>
<h2>View Records</h2>
<table width = "100%" border = "1" style = "border-collapse:collapse;">
<thead>
<tr>
<th><strong>No</strong></th>
<th><strong>Damage ID's</strong></th>
<th><strong>EQ ID's</strong></th>
<th><strong>Student ID's</strong></th>
<th><strong>Staff ID's</strong></th>
<th><strong>Date reported</strong></th>
<th><strong>Date repaired</strong></th>
<th><strong>Equipment Status</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td align = "center">000</td>
<td align = "center">111</td>
<td align = "center">222</td>
<td align = "center">333</td>
<td align = "center">444</td>
<td align = "center">555</td>
<td align = "center">666</td>
<td align = "center">777</td>
<td align = "center">
<a href = "dmgequp.php?damagedID=aaa">Edit</a>
</td>
<td align = "center">
<a href = "dmgeqdelete.php?damagedID=bbb" onclick = "return confirm('Are you sure?'); return false;">Delete</a>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>Спасибо за решение, так что в основном мне нужно остановить дальнейшее выполнение кода href = "dmgeqdelete.php?damagedID=<?php echo $row["damagedID"]; ?>"
Нет, вам не нужно возвращать дополнительное значение false. Нажатие Cancel/No уже возвращает false. Вероятно, у вас была опечатка при первой попытке. Просто помните, что это действительно плохая практика, никогда не манипулируйте переменными GET. Это очистит вашу базу данных. См. здесь: https://jsfiddle.net/ou0szc3r/
Трудно сказать, так как OP не включал свой исходный код, где он использовался, а только ссылался на него. Единственное, что нужно усвоить, это то, что confirm возвращает true или false, и ничего после его запуска, как вы можете видеть из jsfiddle. Вы даже можете удалить return false; из своего фрагмента и заметить, что это не имеет значения.
Используйте фактическую функцию прослушивания кликов, где вы обрабатываете подтверждение, затем ajax для POST данных в php и PDO с подготовленными операторами в php.