suttercain Posted December 12, 2007 Share Posted December 12, 2007 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 Quote Link to comment Share on other sites More sharing options...
zq29 Posted December 12, 2007 Share Posted December 12, 2007 You have your name and value around the wrong way... input type="hidden" name="<?php echo $_POST['terms']; ?>" value="terms" /> Should be: input type="hidden" name="terms" value="<?php echo $_POST['terms']; ?>" /> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.