【问题标题】:Pagination link not work properly?分页链接不能正常工作?
【发布时间】:2016-06-12 08:27:11
【问题描述】:

分页不能正常工作?

我将此代码保存在“Forum-Com.php”文件中,当我打开此文件时,分页工作正常且正确,但当我将此文件包含在另一个页面中时,其打开的第一页正确,但当我单击第二个或另一个时页面链接它会打开第一页上的相同 cmets。请帮我。 (我正在使用 Scriptsmi​​ll cmets 脚本 v1.06 和来自 admin.php 的函数 make_pages_string)

 $COM_CONF['full_path'] = dirname(__FILE__);


 function make_pages_string ($all_count, $records_per_page, $cur_page, $base_url) {

if ($all_count > $records_per_page) {
    if ($cur_page > 0) { $cur_page=$cur_page-1; }
    $first_record = ($cur_page) * $records_per_page;
    $limit_string = "LIMIT $first_record, $records_per_page";
    $pages=$all_count/$records_per_page;
    if ($pages > (int) $pages) { $pages=(int)$pages+1; }
}
if ($pages>1) {
    $pages_string.="Page: ";
    if ($cur_page>10 && $pages>20) { $first_page=$cur_page-9; }
    else { $first_page=1; }
    if ($pages>20 && ($cur_page+10)<$pages) { $last_page=$first_page+19; }
    else { $last_page=$pages; }
    if ($cur_page+1>1) {
        $prev=$cur_page;
        $pages_string.="<a href='$base_url&page=$prev'>&lt</a>&nbsp;&nbsp; ";
    }
    for ($i=$first_page; $i<=$last_page; $i++){
        if ($i != $cur_page+1) {
            $pages_string.="<a href='$base_url&page=$i'>$i</a>&nbsp; ";
        }
        else {
            $pages_string.="<b>$i</b>&nbsp; ";
        }
    }
    if ($cur_page+1<$pages) {
        $next=$cur_page+2;
            $pages_string.="<a href='$base_url&page=$next'>&gt</a>&nbsp;&nbsp; ";
        }                                     

}
return array ($pages_string, $limit_string);
 }



 function smcom_view()
 {
  global $comments_db_link, $COM_CONF, $COM_LANG;

$result = mysql_query("select COUNT(id) from {$COM_CONF['dbmaintable']}", $comments_db_link);
list ($all_count) = mysql_fetch_row($result);
list ($pages_string, $limit_string) = make_pages_string ($all_count, 10, $_REQUEST['page'], "{$COM_CONF['base_url']}?action=view");

$result = mysql_query("select time, text, author, email, dont_show_email from {$COM_CONF['dbmaintable']} order by time {$COM_CONF['sort_order']} $limit_string", $comments_db_link);


$comments_count=0;
$id=$time=$text=$author=$email=$dont_show_email=$ip=array();
while (list($id[$comments_count], $time[$comments_count], $text[$comments_count], $author[$comments_count], $email[$comments_count], $dont_show_email[$comments_count], $ip[$comments_count])=mysql_fetch_array($result)) {
    $comments_count++;
}

  require("{$COM_CONF['full_path']}/templates/Forum-default.php");

  }

【问题讨论】:

  • @Sajid,现在它可以正常工作了。但是一个问题是,当我使用“mysql_escape_string”时它不起作用,只有第一页显示带有限制和页面链接的 cmets,但第二页或其他页面不显示 cmets 或分页链接,只显示“还没有 cmets”。跨度>

标签: pagination


【解决方案1】:

上面给出的代码完全没有问题。问题在于服务器配置关闭了 $_REQUEST 全局变量的直接访问。

【讨论】:

  • 我还有一个问题,当有人在某个页面上添加评论时,它会正确显示,但是当有人在该页面的第二页左右评论时,评论永远不会显示。任何帮助将不胜感激,谢谢。
猜你喜欢
  • 2023-03-28
  • 2014-12-15
  • 1970-01-01
  • 1970-01-01
  • 2018-04-13
  • 2018-06-11
相关资源
最近更新 更多