2016-06-12 163 views
0

分页无法正常工作?分页链接无法正常工作?

我将这段代码保存在“Forum-Com.php”文件中,当我打开此文件时,分页工作正常正确,但是当我将此文件包含在另一页中时,它正确打开第一页,但当我单击第二页或另一页链接打开第一页上的相同注释。请帮帮我。 (我用Scriptsmi​​ll评论脚本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"); 

    } 
+0

@Sajid,现在它工作正常。但是一个问题是,当我使用“mysql_escape_string”时,它不起作用,只有第一页显示带有限制和页面链接的注释,但是第二页或其他页面不显示注释或分页链接,只说“没有评论”。 –

回答

0

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

+0

我还有一个问题,当某人在某个页面上添加评论时,它显示正确,但是当某人在某个页面的第二页左右发表评论时,评论从不显示。任何帮助将不胜感激,谢谢。 –