Jump to content

How do I get a post variable from page 1 to page 2, 3, 4, etc using Pagination?


suttercain

Recommended Posts

Hi guys,

 

I am using the basic pagination for a query result.

 

<?php

//PAGENATION
if (isset($_GET['pageno'])) {
   $pageno = $_GET['pageno'];
   $i = $pageno * 25 - 24;
} else {
   //$pageno = 1;
   $i = 1;
}

//PAGINATION
$query = mysql_query("SELECT count(*) FROM masterList WHERE decs ='$decs'"); 
$query_data = mysql_fetch_row($query);
$numrows = $query_data[0];
$rows_per_page = 25;
$lastpage = ceil($numrows/$rows_per_page);
$pageno = (int)$pageno;
if ($pageno < 1) {
   $pageno = 1;
} elseif ($pageno > $lastpage) {
   $pageno = $lastpage;
}
$limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page;


$sql = "SELECT * FROM masterList WHERE decs ='$decs' ORDER BY mfr $limit";      



} elseif (isset($_SESSION['enf']) && $_SESSION['enf'] != "") {
$engFam = $_SESSION['enf'];
$matching = $engFam;
$sql = "SELECT * FROM masterList WHERE engFam ='$engFam' ORDER BY mfr";
} elseif (isset($_SESSION['year']) && isset($_SESSION['disp']) && isset($_SESSION['mfr']) && $_SESSION['year'] != 0) {
$year = $_SESSION['year'];
$disp = $_SESSION['disp'];
$mfr = $_SESSION['mfr'];
$matching = $year. " ". $disp . " " .$mfr;
$sql = "SELECT * FROM masterList WHERE year ='$year' AND disp ='$disp' AND mfr='$mfr' ORDER BY mfr";
}

$results = mysql_query($sql) or die(mysql_error());

//show results

if ($pageno == 1) {
   echo " << < ";
} else {
   echo " <a href='{$_SERVER['PHP_SELF']}?pageno=1'><<</a> ";
   $prevpage = $pageno-1;
   echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage'><</a> ";
}
echo "  Page $pageno of $lastpage  ";

if ($pageno == $lastpage) {
   echo " > >> ";
} else {
   $nextpage = $pageno+1;
   echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'>></a> ";
   echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$lastpage'>>></a> ";
}
  if ($pageno == 1) {
   $i = 1;
  } else {
   $i = $pageno * 25 - 24;
  }

?>

 

The problem I am having is that I need two post variables to carry over if the user goes to page 2 or any other page. I tried using

 

<form method="post">
<input type="hidden" name="proceed" value="proceed" />
<input type="hidden" name="<?php echo $_POST['terms']; ?>" value="terms" />
</form>

 

But this didn't work. Any ideas?

 

Thanks ahead of time.

 

SC

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.