'." "; // Goto last page -6ren">
gpt4 book ai didi

php - Div 没有在 mysql 结果 php 中被回显

转载 作者:行者123 更新时间:2023-11-29 02:55:09 24 4
gpt4 key购买 nike

所以首先让我通过我的代码

<div class="Page_Navigation"><?php 
$sql = "SELECT id, name, banner, description, sponsor, votes, hits FROM websites";
$rs_result = mysql_query($sql); //run the query
$total_records = mysql_num_rows($rs_result); //count number of records
$total_pages = ceil($total_records / $num_rec_per_page); ?>
<div class="Page_Navigation"><?
echo "<a href='index.php?page=1'>".'<'."</a> "; // Goto 1st page
for ($i=1; $i<=$total_pages; $i++) {
echo "<a href='index.php?page=".$i."'>".$i."</a> ";
};
echo "<a href='index.php?page=$total_pages'>".'>'."</a> "; // Goto last page
?></div>

这是它的外观图片:

它应该是这样的:

不仅如此,链接也失效了:

page=

最佳答案

使用mysqli_*PDO。查看代码:-

尝试在 for 循环 之前移动您的 div 代码:-

<?php
error_reporting(E_ALL); // check all type of error
ini_set('display_errors',1); // display errors if any
$conn = mysqli_connect('server name','user name','password','database name') or die(mysqli_connect_error); // connect to database

$sql = "SELECT id, name, banner, description, sponsor, votes, hits FROM websites";
$rs_result = mysqli_query($sql) or die(mysqli_error($conn)); //run the query
$total_records = mysqli_num_rows($rs_result); //count number of records
$total_pages = ceil($total_records / $num_rec_per_page);

echo "<a href='index.php?page=1'>".''."</a>"; // Go to 1st page
echo '<div class="Page_Navigation">';
for ($i=1; $i<=$total_pages; $i++) {

echo "<a href=index.php?page=$i>$i</a>";
}

echo "<a href=index.php?page=$total_pages></a></div>"; // Go to last page
?>

关于php - Div 没有在 mysql 结果 php 中被回显,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31416546/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com