2011-11-24 106 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