2011-11-24 75 views
-1

我不明白爲什麼我的分頁不工作!它默認顯示爲ok,但是當點擊'Next'頁面或某個頁面編號時,什麼也沒有發生,根本不改變頁面。這就像不識別pagination.js或pagination_class.php。 我有網站的另一部分工作正常,所以我不確定是否錯過這裏明顯的東西? 在同一個文件夾中有4個文件涉及到:myaccount_betinghistory.php, myaccount_bettinghistory_sub.php, pagination.js, pagination_class.php.分頁 - 不工作

這裏是所有需要查看的文件的所有代碼,我希望你能在那裏找到bug!

myaccount_bettinghistory.php:

<?php 

error_reporting(E_ALL^E_NOTICE); 
include('pagination_class.php'); 

?> 

<script language="JavaScript" src="pagination.js"></script> 
<link rel="stylesheet" type="text/css" href="style.css" /> 


<?PHP 

//Session start 
@session_start(); 

//Path to root 
$root = realpath($_SERVER["DOCUMENT_ROOT"]); 

//Require Init 
$mode = array(); 
$mode[] = 'nohtml'; 
require_once $root . "/inc/php/init.php"; 

{ 

?> 

<?PHP 

} 

?> 

<? 
$qry = " 
SELECT timelive,bidprice,match_title,selection,winnings_with_startamount,odds,odds*10 AS gainedodds,username, 
CASE 
WHEN each_bid_recorded_Part2.result liKE '' AND each_bid_recorded_Part2.status LIKE 'E' THEN 'pending' 
WHEN each_bid_recorded_Part2.result liKE '' AND each_bid_recorded_Part2.status NOT LIKE 'E' THEN 'active' 
WHEN each_bid_recorded_Part2.result liKE each_bid_recorded_Part2.selection THEN 'WON' 
WHEN each_bid_recorded_Part2.result NOT liKE each_bid_recorded_Part2.selection THEN 'LOST' 
END AS result 
FROM each_bid_recorded_Part2 WHERE each_bid_recorded_Part2.username LIKE '" . $_SESSION['username'] . "' 

"; 

$qry .= " ORDER BY timelive DESC"; 


//for pagination 
$starting=0; 
$recpage = 4;//number of records per page 

$obj = new pagination_class($qry,$starting,$recpage);  
$result = $obj->result; 



function getStyleColorForStatus($status) { 
    if ($status == 'WON') { 
return '#99ff99'; 
    } 
    else if ($status == 'LOST') { 
return '#ff9999'; 
    } 
    else if ($status == 'pending') { 
return '#e5e5e5'; 
    } 
    else if ($status == 'active') { 
return '#ffffcc'; 
    } 
    return ''; 
} 



?> 


<div> 
    <div class="pageTop"><img src="images/icons/faqicon.png" width="37" height="37" align=absbottom>  Betting History</div> 
    <tr> 
    <td>&nbsp;</td> 
    </tr> 
</div> 
    <div> 
<p style="font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif; color: #535252; text-align: left;">Check your bets with you as a last bidder.</p> 
</div> 
<table width="600" border="0" cellspacing="0" cellpadding="0" style="font-size:11px; color: #535252;"> 
     <form name="form1" action="myaccount_bettinghistory.php" method="POST" style="background-color:#f9f9f9; -webkit-box-shadow: 0 1px 10px rgba(0,0,0,.1); -moz-box-shadow: 0 1px 10px rgba(0,0,0,.1); box-shadow: 0 1px 10px rgba(0,0,0,.1);"> 

     <table border="0" align="left" width="500px" padding-left="0px" style="background:#F9F9F9;"> 



     <tr><TD colspan="0"> 

     <div id="page_contents"> 

      <table width="755px" cellspacing="0" cellpadding="5" align="center" frame="box" rules="none" style="padding-bottom:2px; margin-bottom:0px; margin-top:3px; -webkit-box-shadow: 0 1px 10px rgba(0,0,0,.1); -moz-box-shadow: 0 1px 10px rgba(0,0,0,.1); box-shadow: 0 1px 10px rgba(0,0,0,.1); border: 1px solid #cccccc;"> 
      <tr style="height: 40px;"> 
<td width="30%" align="center" td class="winheader"><div class="glowtext">Event Start Time</div></td></td> 
<td width="10%" align="center" td class="winheader"><div class="glowtext">Bid Cost</div></td></td> 
<td width="35%" align="center" td class="winheader"><div class="glowtext">Market/Event</div></td></td> 
<td width="10%" align="center" td class="winheader"><div class="glowtext">Selection</div></td></td> 
<td width="10%" align="center" td class="winheader"><div class="glowtext">Winnings</div></td></td> 
<td width="5%" align="center" td class="winheader"><div class="glowtext">Odds</div></td></td> 
<td width="5%" align="center" td class="winheader"><div class="glowtext">Gained Odds</div></td></td> 
<td width="10%" align="center" td class="winheader"><div class="glowtext">Winning Bidder</div></td></td> 
<td width="5%" align="center" td class="winheader"><div class="glowtext">Final Result</div></td></td> 
      </tr> 
      <?if(mysql_num_rows($result)!=0){ 
       $counter = $starting + 1; 
       while($data = mysql_fetch_array($result)) {?> 



    <tr class="initial" onMouseOver="this.className='highlight'" onMouseOut="this.className='normal'"> 



        <td align="center"><font color="#333"><? echo $data['timelive']; ?></TD> 
        <td align="center">&euro; <? echo $data['bidprice']; ?></TD>   
        <td align="left"><font color="#0070c0"><? echo $data['match_title']; ?></TD>     
        <td align="left"><? echo $data['selection']; ?></TD> 
        <td align="center"><font color="green">&euro; <? echo $data['winnings_with_startamount']; ?></TD> 
        <td align="center"><? echo $data['odds']; ?></TD> 
        <td align="center"><? echo $data['gainedodds']; ?></TD> 
        <td align="center"><? echo $data['username']; ?></TD> 
        <td align="center" style="background-color:<?php echo getStyleColorForStatus($data['result']); ?>"><? echo $data['result']; ?></td> 
        </tr> 


       <? 
        $counter ++; 
       } ?> 


       <tr><TD align="center" colspan="10" style="padding-bottom:1px; padding-top:10px; color:#333;"><? echo $obj->anchors; ?></TD></tr> 
       <tr><TD align="center" colspan="10" style="padding-bottom:10px; padding-top:5px; color:#333;"><? echo $obj->total; ?></TD></tr> 
      <?}else{?> 
       <tr><TD align="center" colspan="10" style="padding-bottom:10px padding-top:10px; color:red;">No Data Found</TD></tr> 
      <?}?> 
      </TD></tr> 
      </table> 
     </div> 
     </tr> 
     </TD> 
    </form> 
</table> 

<STYLE> 

*{ margin-bottom:0; } 



#pagination-flickr li{ 
margin:0px; 
padding:0px; 
float:left; 
font-size:10px; 
} 
#pagination-flickr a{ 
float:left; 
padding:5px 7px; 
margin-right:5px; 
border:solid 1px #4d7dc5; 
text-decoration:none; 
background:#FFFFFF; 
color:#4d7dc5; 
font-size:10px; 
} 
#pagination-flickr .previous-off, 
#pagination-flickr .next-off { 
border:solid 1px #DDDDDD; 
cursor:default; 
background:#FFFFFF; 
border:solid 1px #BBBBBB; 
color:#BBBBBB; 
padding:4px 6px; 
margin-right:5px; 
font-size:10px; 
} 
#pagination-flickr .next a, 
#pagination-flickr .previous a { 
background:#FFFFFF; 
border:solid 1px #BBBBBB; 
color:#BBBBBB; 
font-size:10px; 
} 
#pagination-flickr .active{ 
cursor:default; 
background:#4d7dc5; 
color:#FFFFFF; 
padding:4px 6px; 
margin-right:5px; 
border:solid 1px #4d7dc5; 
font-size:10px; 
} 
#pagination-flickr a:link, 
#pagination-flickr a:visited { 
padding:4px 6px; 
margin-right:5px; 
border:solid 1px #4d7dc5; 
background:#FFFFFF; 
color:#4d7dc5; 
font-size:10px; 
} 
#pagination-flickr a:hover{ 
padding:4px 6px; 
margin-right:5px; 
border:solid 1px #4d7dc5; 
background:#ffc04a; 
color:#000; 
font-size:10px; 
} 


body,table 
{ 

font-family:Verdana, Arial, Helvetica, sans-serif; 
font-size:11px; 
padding-bottom:5px; 
empty-cells: show; 


} 

.glowtext 
{ 
text-shadow: 0 0 20px white; 
color:#333; 
font-weight:bold; 
} 


</STYLE> 

myaccount_bettinghistory_sub.php:

<?php 
error_reporting(E_ALL^E_NOTICE); 
include('pagination_class.php'); 

?> 

<script language="JavaScript" src="pagination.js"></script> 
<link rel="stylesheet" type="text/css" href="style.css" /> 

<?PHP 

//Session start 
@session_start(); 

//Path to root 
$root = realpath($_SERVER["DOCUMENT_ROOT"]); 

//Require Init 
$mode = array(); 
$mode[] = 'nohtml'; 
require_once $root . "/inc/php/init.php"; 


{ 
?> 

<?PHP 
} 

?> 


<? 
$qry = " 
SELECT timelive,bidprice,match_title,selection,winnings_with_startamount,odds,odds*10 AS gainedodds,username, 
CASE 
WHEN each_bid_recorded_Part2.result liKE '' AND each_bid_recorded_Part2.status LIKE 'E' THEN 'pending' 
WHEN each_bid_recorded_Part2.result liKE '' AND each_bid_recorded_Part2.status NOT LIKE 'E' THEN 'active' 
WHEN each_bid_recorded_Part2.result liKE each_bid_recorded_Part2.selection THEN 'WON' 
WHEN each_bid_recorded_Part2.result NOT liKE each_bid_recorded_Part2.selection THEN 'LOST' 
END AS result 
FROM each_bid_recorded_Part2 WHERE each_bid_recorded_Part2.username LIKE '" . $_SESSION['username'] . "' 

"; 

$qry .= " ORDER BY timelive DESC"; 


//for pagination 
if(isset($_GET['starting'])&& !isset($_REQUEST['submit'])){ 
$starting=$_GET['starting']; 
}else{ 
$starting=0; 
} 
$recpage = 4;//number of records per page 

$obj = new pagination_class($qry,$starting,$recpage);   
$result = $obj->result; 



function getStyleColorForStatus($status) { 
    if ($status == 'WON') { 
return '#99ff99'; 
    } 
    else if ($status == 'LOST') { 
return '#ff9999'; 
    } 
    else if ($status == 'pending') { 
return '#e5e5e5'; 
    } 
return ''; 
} 



?> 


<div> 
    <div class="pageTop"><img src="images/icons/faqicon.png" width="37" height="37" align=absbottom>  Betting History</div> 
    <tr> 
    <td>&nbsp;</td> 
    </tr> 
</div> 
    <div> 
<p style="font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif; color: #535252; text-align: left;">Check your bets with you as a last bidder.</p> 
    </div> 
<table width="600" border="0" cellspacing="0" cellpadding="0" style="font-size:11px; color: #535252;"> 
    </div>   
</div>   
     <table border="0" align="left" width="500px" padding-left="0px" style="background:#F9F9F9;"> 



     <tr><TD colspan="0"> 

     <div id="page_contents"> 

      <table width="98%" cellspacing="0" cellpadding="5" align="center" frame="box" rules="none" style="padding-bottom:2px; margin-bottom:0px; margin-top:3px; -webkit-box-shadow: 0 1px 10px rgba(0,0,0,.1); -moz-box-shadow: 0 1px 10px rgba(0,0,0,.1); box-shadow: 0 1px 10px rgba(0,0,0,.1); border: 1px solid #cccccc;"> 
      <tr style="height: 40px;"> 
<td width="30%" align="center" td class="winheader"><div class="glowtext">Event Start Time</div></td></td> 
<td width="10%" align="center" td class="winheader"><div class="glowtext">Bid Cost</div></td></td> 
<td width="35%" align="center" td class="winheader"><div class="glowtext">Market/Event</div></td></td> 
<td width="10%" align="center" td class="winheader"><div class="glowtext">Selection</div></td></td> 
<td width="10%" align="center" td class="winheader"><div class="glowtext">Winnings</div></td></td> 
<td width="5%" align="center" td class="winheader"><div class="glowtext">Odds</div></td></td> 
<td width="5%" align="center" td class="winheader"><div class="glowtext">Gained Odds</div></td></td> 
<td width="10%" align="center" td class="winheader"><div class="glowtext">Winning Bidder</div></td></td> 
<td width="5%" align="center" td class="winheader"><div class="glowtext">Final Result</div></td></td> 
      </tr> 
      <?if(mysql_num_rows($result)!=0){ 
       $counter = $starting + 1; 
       while($data = mysql_fetch_array($result)) {?> 



    <tr class="initial" onMouseOver="this.className='highlight'" onMouseOut="this.className='normal'"> 


        <td align="center"><font color="#333"><? echo $data['timelive']; ?></TD> 
        <td align="center">&euro; <? echo $data['bidprice']; ?></TD>   
        <td align="left"><font color="#0070c0"><? echo $data['match_title']; ?></TD>     
        <td align="left"><? echo $data['selection']; ?></TD> 
        <td align="center"><font color="green">&euro; <? echo $data['winnings_with_startamount']; ?></TD> 
        <td align="center"><? echo $data['odds']; ?></TD> 
        <td align="center"><? echo $data['gainedodds']; ?></TD> 
        <td align="center"><? echo $data['username']; ?></TD> 
        <td align="center" style="background-color:<?php echo getStyleColorForStatus($data['result']); ?>"><? echo $data['result']; ?></td> 
        </tr> 


       <? 
        $counter ++; 
       } ?> 


       <tr><TD align="center" colspan="10" style="padding-bottom:1px; padding-top:10px; color:#333;"><? echo $obj->anchors; ?></TD></tr> 
       <tr><TD align="center" colspan="10" style="padding-bottom:10px; padding-top:5px; color:#333;"><? echo $obj->total; ?></TD></tr> 
      <?}else{?> 
       <tr><TD align="center" colspan="10" style="padding-bottom:10px padding-top:10px; color:red;">No Data Found</TD></tr> 
      <?}?> 
      </TD></tr> 
      </table> 
     </div> 
     </tr> 
     </TD> 

    </table> 

pagination.js:

var xmlHttp 

function pagination(page) 
{ 
xmlHttp=GetXmlHttpObject(); 
if (xmlHttp==null) 
    { 
    alert ("Your browser does not support AJAX!"); 
    return; 
    } 
var url="myaccount_bettinghistory_sub.php"; 
url = url+"?starting="+page; 
url = url+"&search_text="+document.form1.search_text.value; 
url=url+"&sid="+Math.random(); 
xmlHttp.onreadystatechange=stateChanged; 
xmlHttp.open("GET",url,true); 
xmlHttp.send(null); 
} 

function stateChanged() 
{ 
if (xmlHttp.readyState==4) 
{ 
document.getElementById("page_contents").innerHTML=xmlHttp.responseText; 
} 
} 

function GetXmlHttpObject() 
{ 
var xmlHttp=null; 
try 
    { 
    // Firefox, Opera 8.0+, Safari 
    xmlHttp=new XMLHttpRequest(); 
    } 
catch (e) 
    { 
    // Internet Explorer 
    try 
    { 
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); 
    } 
    catch (e) 
    { 
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); 
    } 
    } 
return xmlHttp; 
} 

pagination_class.php:

<? 
/* 
Developed by Reneesh T.K 
[email protected] 
You can use it with out any worries...It is free for you..It will display the out put like: 
First | Previous | 3 | 4 | 5 | 6 | 7| 8 | 9 | 10 | Next | Last 
Page : 7 Of 10 . Total Records Found: 20 
*/ 
class Pagination_class{ 
var $result; 
var $anchors; 
var $total; 
function Pagination_class($qry,$starting,$recpage) 
{ 
    $rst  = mysql_query($qry) or die(mysql_error()); 
    $numrows = mysql_num_rows($rst); 
    $qry   .= " limit $starting, $recpage"; 
    $this->result = mysql_query($qry) or die(mysql_error()); 
    $next  = $starting+$recpage; 
    $var  = ((intval($numrows/$recpage))-1)*$recpage; 
    $page_showing = intval($starting/$recpage)+1; 
    $total_page = ceil($numrows/$recpage); 

    if($numrows % $recpage != 0){ 
     $last = ((intval($numrows/$recpage)))*$recpage; 
    }else{ 
     $last = ((intval($numrows/$recpage))-1)*$recpage; 
    } 
    $previous = $starting-$recpage; 
    $anc = "<ul id='pagination-flickr'>"; 
    if($previous < 0){ 
     $anc .= "<li class='previous-off'><<</li>"; 
     $anc .= "<li class='previous-off'><</li>"; 
    }else{ 
     $anc .= "<li class='next'><a href='javascript:pagination(0);'><< </a></li>"; 
     $anc .= "<li class='next'><a href='javascript:pagination($previous);'>< </a></li>"; 
    } 

    ################If you dont want the numbers just comment this block############### 
    $norepeat = 4;//no of pages showing in the left and right side of the current page in the anchors 
    $j = 1; 
    $anch = ""; 
    for($i=$page_showing; $i>1; $i--){ 
     $fpreviousPage = $i-1; 
     $page = ceil($fpreviousPage*$recpage)-$recpage; 
     $anch = "<li><a href='javascript:pagination($page);'>$fpreviousPage </a></li>".$anch; 
     if($j == $norepeat) break; 
     $j++; 
    } 
    $anc .= $anch; 
    $anc .= "<li class='active'>".$page_showing."</li>"; 
    $j = 1; 
    for($i=$page_showing; $i<$total_page; $i++){ 
     $fnextPage = $i+1; 
     $page = ceil($fnextPage*$recpage)-$recpage; 
     $anc .= "<li><a href='javascript:pagination($page);'>$fnextPage</a></li>"; 
     if($j==$norepeat) break; 
     $j++; 
    } 
    ############################################################ 
    if($next >= $numrows){ 
     $anc .= "<li class='previous-off'>></li>"; 
     $anc .= "<li class='previous-off'>>></li>"; 
    }else{ 
     $anc .= "<li class='next'><a href='javascript:pagination($next);'>> </a></li>"; 
     $anc .= "<li class='next'><a href='javascript:pagination($last);'>>></a></li>"; 
    } 
     $anc .= "</ul>"; 
    $this->anchors = $anc; 

    $this->total = "Page : $page_showing of $total_page &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Total Records Found: $numrows"; 
} 
} 
?> 
+0

在您的Web服務器錯誤日誌和/或JavaScript控制檯中是否有任何內容? – Trott

+0

恩,對不起,聽起來很傻,但我實際上並沒有那麼多的經驗,所以不知道如何檢查,此刻:( – Ivy

+2

你應該停止你想做的一切,並找出這兩件事情: (1)你的web服務器日誌在哪裏以及如何閱讀它們和(2)如何查看你的JavaScript控制檯 – Trott

回答

0

刪除此

&& !isset($_REQUEST['submit']) 

你不使用它!

+0

刪除它,但沒有幫助,仍然沒有分頁功能 – Ivy

+0

嘗試在firefox中使用firebug來查看javascript發送的內容並嘗試直接運行腳本 – ddjikic

+0

我嘗試了谷歌瀏覽器'檢查元素',並在那裏接收到此錯誤:未捕獲的類型錯誤:無法讀取未定義的屬性'值' 分頁 (匿名函數)' – Ivy