Jump to content

pagination problem


esandra

Recommended Posts

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());

 

$totalcollections = 0;

$y=0; //for bgcolor

                                                while($row=mysql_fetch_array($result)){

if($y % 2==0){

$a="#999";

}

else{

$a="#FFF";

}

$y++;

$totalcollections += $total;

 

                                                    $orno=$row['orno'];

                                                    $billnmbr=$row['billnmbr'];

                                                    $payor=$row['payor'];

                                                    $arrastre=$row['arrastre'];

                                                    $wharfage=$row['wharfage'];

                                                    $total=$row['total'];

                                                    $date=$row['date'];                                                   

                                               

                                                    $totformat = number_format($totalcollections,2);

                                                    $arrformat = number_format($arrastre, 2);

                                                    $wharformat = number_format($wharfage, 2);

                                                    $totalformat = number_format($total, 2);

                                                   

                                                    $explode_bill=explode("-",$billnmbr);

                                                   

                                                    $bill1 = 0;

                                                    $bill2 = 0;

                                                   

                                                    $bill1 = $explode_bill[0];

                                                    $bill2 = $explode_bill[1];

                                                   

                                                    if(strlen($bill2)==1){

                                                        $rep = "00000";

                                                        $billnmbr = $bill1."-".$rep."".$bill2;

                                                        }

                                                    elseif(strlen($bill2)==2){

                                                        $rep = "0000";

                                                        $billnmbr = $bill1."-".$rep."".$bill2;

                                                        }

                                                    elseif(strlen($bill2)==3){

                                                        $rep = "000";

                                                        $billnmbr = $bill1."-".$rep."".$bill2;

                                                        }

                                                    elseif(strlen($bill2)==4){

                                                        $rep = "00";

                                                        $billnmbr = $bill1."-".$rep."".$bill2;

                                                        }

                                                    elseif(strlen($bill2)==5){

                                                        $rep = "0";

                                                        $billnmbr = $bill1."-".$rep."".$bill2;

                                                        }

                                                    else{

                                                        $rep = "000000";

                                                        $billnmbr = $bill1."-".$rep."".$bill2;

                                                        }

                                        ?>//this is my display

                                        <tr bgcolor="<?php echo $a;?>">

                                            <td height="20" align="center"><?php echo $orno;?>

                                            <td align="left"><?php echo $billnmbr;?>

                                          <td align="left"><?php echo $payor;?>

                                            <td align="right"><?php echo $arrformat;?>

                                            <td align="right"><?php echo $wharformat;?>

                                            <td align="right"><?php echo $totalformat;?>

                                      </tr>

                                        <?php }

                                           

                                        ?>                                       

                                      <tr>

                                        <td colspan="4">

                                            <td align="right">on page total:

                                            <td align="right"><?php echo $totformat;?>

                                        </tr>

                                    </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>

Link to comment
https://forums.phpfreaks.com/topic/212646-pagination-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.