2016-06-12 157 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

我還有一個問題,當某人在某個頁面上添加評論時,它顯示正確,但是當某人在某個頁面的第二頁左右發表評論時,評論從不顯示。任何幫助將不勝感激,謝謝。 –