动态分页取决于mySQL数据库中的行数 [英] Dynamic pagination depending on the number of rows in mySQL database
本文介绍了动态分页取决于mySQL数据库中的行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为我的mySQL数据库做一个动态分页。每页结果为20,页数(显示在底部)依赖于 $ totalPages
我目前在 for-loop
之后有一些麻烦的字符串转义。有人可以帮我复查吗?
$ result = mysql_query(SELECT COUNT(0)FROM Spreadsheet);
$ rows = mysql_fetch_array($ result);
$ total = $ rows [0];
$ totalPages = ceil($ total / 20);
$ i = 0;
$ pages =Pages:;
echo $ pages; ($ i; $ i <$ totalPages; $ i ++){
echo< a href = \index.php?page ='$ i'rpp = 20
\ > $ I< / A> 中;
$ p
$ b 结果应该如下所示:
页数:1,2,3,4,5等。
感谢您的帮助!
解决方案
for($ i; $ i <$ totalPages; $ i ++){
echo'< a href =index.php?page ='。$ i。'& rpp = 20> [ $ I。 ']< / A>';
}
I am trying to do a dynamic paging for my mySQL database. Results per page are 20, and the number of pages (displayed at the bottom) is dependent on $totalPages
I am currently having some trouble escaping strings after the for-loop
. Can someone help me double check?
$result = mysql_query("SELECT COUNT(0) FROM Spreadsheet");
$rows = mysql_fetch_array($result);
$total = $rows[0];
$totalPages = ceil($total/20);
$i=0;
$pages = "Pages :";
echo $pages;
for ($i; $i<$totalPages; $i++){
echo "<a href=\"index.php?page='$i'rpp=20\">$i</a>";
}
The results should look like this:
Pages: 1, 2, 3, 4, 5, etc..
Thank you for the help!
解决方案 for ($i; $i<$totalPages; $i++){
echo '<a href="index.php?page='.$i.'&rpp=20">['.$i.']</a>';
}
这篇关于动态分页取决于mySQL数据库中的行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文