pages Posted April 13, 2010 Share Posted April 13, 2010 Ok i have a script and i know exactly whats going wrong with it i just dont know a way around it At the header of the file i do all my usual includes and what not <?php require_once('auth.php'); require_once('config.php'); require_once('opendb.php'); session_start(); $user = $_SESSION['SESS_USERNAME']; $id= $_SESSION['SESS_MEMBER_ID']; $sex = $_POST['sex']; $county = $_POST['county']; $minage = $_POST['minage']; $maxage = $_POST['maxage']; ?> Now the problem is when the pagination script calls the PHP_SELF I think this script actively looks for these values again from the posting page. Is there a way to set them and them to remain a value unchangable Kinda like static void in Java ? ill post the entire script even though it dont thinks its necessary but you never know ! <?php require_once('auth.php'); require_once('config.php'); require_once('opendb.php'); session_start(); $user = $_SESSION['SESS_USERNAME']; $id= $_SESSION['SESS_MEMBER_ID']; $sex = $_POST['sex']; $county = $_POST['county']; $minage = $_POST['minage']; $maxage = $_POST['maxage']; ?><head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="style.css" media="screen" title="style (screen)" /> <title></title> </head> <body> <table width=100% height="100" border="0" cols="10"> <tr> <td height="100" colspan="11"><h1> eHarmonize </h1> <h2>'Cause you hate being a loner !' </h2></td> <td width="18%" colspan=""><img href="in.php" name="Window" src="images/hands.jpg" width="292" height="162"> <td></td></td> </tr> </table> <br/> <br/> <table width="100%" border="0"> <td > <div align="center"> <a href="home_Profile.php"title="View and change your profile!"><b><span>My Profile</span></b></a></div></td > <td > <div align="center"><a href="inbox.php" title="Read mail and message others!"><b><span>Mail</span></b></a></div> </td > <td > <div align="center"> <a href="search.php" title="Search for other users!"><b><span>Search for love</span></b></a></div></td > <td > <div align="center"><a href="favourites.php" title="View your favourties!"><b><span>Favourites</span></b></a></div></td > <td > <div align="center"> <a href="logout.php" title="Log off the website!"><b><span>Logout</span></b></a></div></td > </table> <div id="container"> <br/><br/><br/><br/> <div id="left-column"> <div id="menu11"> <ul> <li><a href="search_Compatibility.php">Search By Compatibility </a></li> <li><a href="search_Area.php">Search By Area</a></li> <li><a href="search_Name.php">Search By Name</a></li> </ul> </div> </div> <?php // find out how many rows are in the table $sql = "SELECT COUNT(*) as number FROM members INNER JOIN member_details ON members.member_id = member_details.user_id INNER JOIN rtchoice ON members.member_id = rtchoice.rtchoice_id INNER JOIN alchoice ON members.member_id = alchoice.alchoice_id WHERE rtchoice.sex =$sex AND alchoice.county = '$county' AND members.dob BETWEEN DATE_SUB( CURDATE( ) , INTERVAL $maxage YEAR ) AND DATE_SUB( CURDATE( ) , INTERVAL $minage YEAR )"; //$sql = "SELECT COUNT(*) FROM members"; $result = mysql_query($sql) or die (mysql_error()); $r = mysql_fetch_row($result); $numrows = $r[0]; $number = $r['number']; // number of rows to show per page $rowsperpage = 5; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; ?> <?php // get the info from the db $sql = "SELECT members.dob, members.login, members.member_id, member_details.interests FROM members INNER JOIN member_details ON members.member_id = member_details.user_id INNER JOIN rtchoice ON members.member_id = rtchoice.rtchoice_id INNER JOIN alchoice ON members.member_id = alchoice.alchoice_id WHERE rtchoice.sex =$sex AND members.member_id <> $id AND members.allowed = 1 AND members.complete = 1 AND alchoice.county = '$county' AND members.dob BETWEEN DATE_SUB( CURDATE( ) , INTERVAL $maxage YEAR ) AND DATE_SUB( CURDATE( ) , INTERVAL $minage YEAR ) LIMIT $offset, $rowsperpage"; $result = mysql_query($sql) or die (mysql_error()); // while there are rows to be fetched... while ($list = mysql_fetch_assoc($result)) { $dob = $list['dob']; $member_login = $list['login']; $member_id = $list['member_id']; $interests = $list['interests']; $age = floor((time() - strtotime($dob))/(60*60*24*365.2425)); ?> <div id="content"> <table columns ="3" border="1" witdth ="100%"> <td width="12%"><img src= "show.php?member_id=<?php echo $member_id; ?>" height="94" width="94"></td> <td width="20%"> <a>Name:</a><a href = "user_Profile.php?user_id=<?php echo $member_login; ?>"><name><?php echo $member_login; ?></name><br/> <a>Age:</a> <b><?php echo $age?></b><br /> </td> <td width="50%"> <b> Interests: <b><br/> <z><?php echo $interests ?></z> </td> </div> </table> <?php } // end while /****** build the pagination links ******/ // range of num links to show $range = 3; // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; // echo forward link for lastpage echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ ?> </div> Thanks for any help you may offer Link to comment https://forums.phpfreaks.com/topic/198434-pagination-_post-values/ Share on other sites More sharing options...
ChemicalBliss Posted April 14, 2010 Share Posted April 14, 2010 I'd set them as session variables, eg; $_SESSION['Search']['sex'] = $_POST['sex']; $_SESSION['Search']['county'] = $_POST['county']; $_SESSION['Search']['minage'] = $_POST['minage']; $_SESSION['Search']['maxage'] = $_POST['maxage']; i'd put it all in a search array so it can be easily removed/unset if necessary. -cb- Link to comment https://forums.phpfreaks.com/topic/198434-pagination-_post-values/#findComment-1041406 Share on other sites More sharing options...
pages Posted April 14, 2010 Author Share Posted April 14, 2010 Thanks for that totally forgot about session variables Link to comment https://forums.phpfreaks.com/topic/198434-pagination-_post-values/#findComment-1041523 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.