管理员:
<?php
$per_page=50;
if (isset($_GET["page"]))
{
$page = $_GET["page"];
}
else
{
$page=1;
}
$start_from = ($page-1) * $per_page;
$sql="select * from all_colleges LIMIT $start_from, $per_page";
$result = mysqli_query($link,$sql);
while ($row = mysqli_fetch_array($result))
{
echo "<tr>
<td>".$row['college_id']."</td>
<td>".$row['college_name']."</td>
<td>
<a class='update' title='Update' href='update.php?college_id=".$row['college_id']."'>
edit
</a>
<a class='delete' title='delete' href='delete.php?college_id=".$row['college_id']."'>
delete
</a>
</td>
</tr>";
}
?>
<?php
$query = "select * from all_colleges";
$result = mysqli_query($link, $query);
$total_records = mysqli_num_rows($result);
$total_pages = ceil($total_records / $per_page);
echo "<center><a href='admin.php?page=1' style='padding:10px;'>".'First Page'."</a>";
$skipped = false;
for ($i = 1; $i <= $total_pages; $i++) {
if ($i < 3 || $total_pages- $i < 3 || abs($page - $i) < 3) {
if ($skipped)
echo '<span> ... </span>';
$skipped = false;
echo "<a href='admin.php?page=" . $i . "' style='padding:5px;'>" . $i . "</a>";
} else {
$skipped = true;
}
}
echo "<a href='admin.php?page=$total_pages' style='padding:10px;'>".'Last Page'."</a></center>";
?>
delete.php
<?php
include('../../conn.php');
$college_id=$_GET['college_id'];
$sql = "delete from all_colleges where college_id='$college_id'";
$result = mysqli_query($link,$sql);
if($result)
{
header('location:admin.php');
}
?>
在这段代码中,我在admin.php页面中有一个删除按钮,我在其中使用分页。当我点击删除按钮记录不删除时我不知道为什么?我该如何解决这个问题?请帮忙。
谢谢