dons2211 Posted February 13, 2007 Share Posted February 13, 2007 Hi, I have created a search were users can search for properties by type, location and number of bedrooms. There are 21 properties were location = Omagh. If i search using the location omagh it displays 21 properties. The problem: I have used dreamweaver's recordset navigation bar. The first result page will display results correctly according to my query (eg 1-5 of 21 records). However when I move to the next page all the results are displayed (eg 6-10 of 21 records) forgetting the criteria set in the query and replacing with the default values. Has anyone else had this problem or got a possible solution? Quote Link to comment Share on other sites More sharing options...
JJohnsenDK Posted February 13, 2007 Share Posted February 13, 2007 Some code would be nice... Quote Link to comment Share on other sites More sharing options...
cheezylu Posted February 13, 2007 Share Posted February 13, 2007 I'm not an expert, but this is the code I used to get my paginations to work... (this is assuming your search fields are "s_title" and "s_topic") At top of page session_destroy(); //Setting session variables if( isset( $_POST[ 's_title' ] ) | isset( $_POST[ 's_topic' ] ) ) { $_SESSION['s_title'] = $_POST['s_title']; $_SESSION['s_topic'] = $_POST['s_topic']; } Then I put my search query, then... ////////// START Page Navigation Equations ////////// //results per page $limit = 4; //Sets what we want to pull from database $query_count = "SELECT * FROM tableName WHERE title LIKE '%$s_title%' AND topic LIKE '%$s_topic%' "; //Pulls what we want from the database $result_count = mysql_query($query_count); //This counts the number of items from mysql $totalrows = mysql_num_rows($result_count); if(empty($page)){ $page = 1; } $limitvalue = $page * $limit - ($limit); //Number of Pages $numofpages = $totalrows / $limit; ////////// STOP Page Navigation Equations ////////// In your SELECT statement to pull the records from the database you would use... SELECT * FROM tableName WHERE title LIKE '%$s_title%' AND topic LIKE '%$s_topic%' ORDER BY title ASC LIMIT $limitvalue, $limit And then use this where you want your navigation bar... /////////////////////// Page Navigation /////////////////////// echo("<br>Page Navigation: "); if($page != 1){ $pageprev = $page - 1; echo("<a href=\"page.php?page=$pageprev &title=$s_title &topic=$s_topic\"><<</a> "); }else echo("<font color=\"#cccccc\"><<</font> "); //Printing Actual Page #'s if($numofpages != 1){ for($i = 1; $i <= $numofpages; $i++){ if($i == $page){ echo(" <b>".$i."</b> "); }else{ echo(" <a href=\"page.php?page=$i &title=$s_title &topic=$s_topic\">$i</a> "); } } // This ends the for loop } // end of if if(($totalrows % $limit) >= 1){ if($i == $page){ echo(" <b>".$i."</b> "); }else{ echo(" <a href=\"page.php?page=$i &title=$s_title &topic=$s_topic\">$i</a> "); } } // Ends the if statement //Setting up "NEXT" link if(($totalrows - ($limit * $page)) > 0){ /* This statement checks to see if there are more rows remaining, meaning there are pages in front of the current one. */ $pagenext = $page + 1; echo(" <a href=\"page.php?page=$pagenext &title=$s_title &topic=$s_topic\"> >></a>"); }else{ echo(" <font color=\"#cccccc\">>></font>"); } mysql_free_result($result); Quote Link to comment Share on other sites More sharing options...
dons2211 Posted February 13, 2007 Author Share Posted February 13, 2007 Hi thanks for your help just got it solved. This is happening because I filtered on POST (I filtered the recordset from POST variables), but the navigation links cannot post data. For this to work, I changed the filter to send by GET and not POST. Thank-you for your help. 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.