pagination problem
Posted: Mon Sep 06, 2010 3:14 am
i really can't tell what's wrong with my pagination script..to say the least it isn't working.when i click a number that (the pagination) it wont show me the files that its supposed to. :shrug: ive been looking at this thing the whole week i cant find out what's wrong with this thing
if((isset($_POST['tcl'])) && (isset($_POST['date']))){ //main, disregard top 2 same posts
$tcl=$_POST['tcl'];
$date=$_POST['date'];
//pagination
$page_name="view.php";
$start=$_GET['start']; //global variable if OFF
if(!($start > 0)) { // This variable is set to zero for the first page
$start = 0;
}
$eu = ($start -0);
$limit = 1;
$this1 = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
$query2=" select * from arrastre where `tcl` = '" . $tcl. "' and `date` = '" . $date . "'";
$result2=mysql_query($query2);
echo mysql_error();
$nume=mysql_num_rows($result2);
$query = "select * from `arrastre` where `tcl` = '" . $tcl. "' and `date` = '" . $date . "' order by `tcl` asc";
$result = mysql_query($query) or die(mysql_error());
$orno=$row['orno'];
?>//this is my display
<tr>
<td height="20" align="center"><?php echo $orno;?>
</tr>
<?php }
?>
</table>
</center>
<div align="center">
<?php
$p_limit=5; // This should be more than $limit and set to a value for which links are to be breaked
$p_f=$_GET['p_f']; // To take care global variable if OFF
if(!($p_f > 0)) { // This variable is set to zero for the first page
$p_f = 0;
}
$p_fwd=$p_f+$p_limit;
$p_back=$p_f-$p_limit;
//////////// End of variables for advance paging ///////////////
/////////////// Start the buttom links with Prev and next link with page numbers /////////////////
if($p_f<>0){print "<a href='$page_name?start=$p_back&p_f=$p_back'>PREV $p_limit</a>"; }
//// if our variable $back is equal to 0 or more then only we will display the link to move back ////////
elseif($back >=0 and ($back >=$p_f)) {
print "<a href='$page_name?start=$back&p_f=$p_f'>PREV</a>";
}
//////////////// Let us display the page links at center. We will not display the current page as a link ///////////
for($i=$p_f;$i < $nume and $i<($p_f+$p_limit);$i=$i+$limit){
if($i <> $eu){
$i2=$i+$p_f;
echo " <a href='$page_name?start=$i&p_f=$p_f'>$i</a> ";
}
else { echo "<font face='Verdana' size='2' color=red>$i</font>";} /// Current page is not displayed as link and given font color red
}
///////////// If not in the last page then Next link will be displayed. Here we check that /////
if($this1 < $nume and $this1 <($p_f+$p_limit)) {
print "<a href='$page_name?start=$next&p_f=$p_f'>NEXT</a>";}
elseif($p_fwd < $nume){
print "<a href='$page_name?start=$p_fwd&p_f=$p_fwd'>NEXT $p_limit</a>";
}}
?></div>
if((isset($_POST['tcl'])) && (isset($_POST['date']))){ //main, disregard top 2 same posts
$tcl=$_POST['tcl'];
$date=$_POST['date'];
//pagination
$page_name="view.php";
$start=$_GET['start']; //global variable if OFF
if(!($start > 0)) { // This variable is set to zero for the first page
$start = 0;
}
$eu = ($start -0);
$limit = 1;
$this1 = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
$query2=" select * from arrastre where `tcl` = '" . $tcl. "' and `date` = '" . $date . "'";
$result2=mysql_query($query2);
echo mysql_error();
$nume=mysql_num_rows($result2);
$query = "select * from `arrastre` where `tcl` = '" . $tcl. "' and `date` = '" . $date . "' order by `tcl` asc";
$result = mysql_query($query) or die(mysql_error());
$orno=$row['orno'];
?>//this is my display
<tr>
<td height="20" align="center"><?php echo $orno;?>
</tr>
<?php }
?>
</table>
</center>
<div align="center">
<?php
$p_limit=5; // This should be more than $limit and set to a value for which links are to be breaked
$p_f=$_GET['p_f']; // To take care global variable if OFF
if(!($p_f > 0)) { // This variable is set to zero for the first page
$p_f = 0;
}
$p_fwd=$p_f+$p_limit;
$p_back=$p_f-$p_limit;
//////////// End of variables for advance paging ///////////////
/////////////// Start the buttom links with Prev and next link with page numbers /////////////////
if($p_f<>0){print "<a href='$page_name?start=$p_back&p_f=$p_back'>PREV $p_limit</a>"; }
//// if our variable $back is equal to 0 or more then only we will display the link to move back ////////
elseif($back >=0 and ($back >=$p_f)) {
print "<a href='$page_name?start=$back&p_f=$p_f'>PREV</a>";
}
//////////////// Let us display the page links at center. We will not display the current page as a link ///////////
for($i=$p_f;$i < $nume and $i<($p_f+$p_limit);$i=$i+$limit){
if($i <> $eu){
$i2=$i+$p_f;
echo " <a href='$page_name?start=$i&p_f=$p_f'>$i</a> ";
}
else { echo "<font face='Verdana' size='2' color=red>$i</font>";} /// Current page is not displayed as link and given font color red
}
///////////// If not in the last page then Next link will be displayed. Here we check that /////
if($this1 < $nume and $this1 <($p_f+$p_limit)) {
print "<a href='$page_name?start=$next&p_f=$p_f'>NEXT</a>";}
elseif($p_fwd < $nume){
print "<a href='$page_name?start=$p_fwd&p_f=$p_fwd'>NEXT $p_limit</a>";
}}
?></div>