我制作了一个寻呼系统。标题正常,但我看不到我制作的导航链接。
$datatable = "items";
$results_per_page = 15;
$sql = "SELECT COUNT(ID) AS total FROM ".$datatable;
$result = $conn->query($sql);
$row = $result->fetch_assoc();
$total_pages = ceil($row["total"] / $results_per_page); // calculate total pages with results
for ($i=1; $i<=$total_pages; $i++) { // print links for all pages
echo "<a href='questions.php?page=".$i."'";
if ($i==$page)
echo " class='curPage'";
echo ">".$i."</a> ";
};
为什么没有显示
答案 0 :(得分:1)
您可以尝试以下代码。
for ($i=1; $i<=$total_pages; $i++) { // print links for all pages
$link = "<a href='questions.php?page=".$i."'";
if ($i==$page) {
$link .= " class='curPage'";
}
$link .= ">".$i."</a> ";
echo $link;
};