envexlabs Posted July 3, 2007 Share Posted July 3, 2007 I have a form that submits a search, and then grabs some info from a mysql database. <?php //creates the next and previous buttons to only show 10 messages if($c == 0) { echo('Previous'); echo(" | "); echo('<a href="?c=' . $c = $c + 10 . '">Next</a>'); } else{ echo('<a href="?c=' . ($c - 10) . '">Previous</a>'); echo(" | "); echo('<a href="?c=' . ($c + 10) . '">Next</a>'); } ?> this renders out the next/previous buttons and $c sends the new value to the mySQL query: $search_query = mysql_query('SELECT * FROM `entries` WHERE `' . $table . '` LIKE "%' . $search .'%" ORDER BY `ID` ASC LIMIT ' . $c . ', 10') or die(mysql_error()); Once i click on "next", the POST values are cleared and the mySQL renders out nothing. How can i make the POST values stay for multiple pages? Quote Link to comment Share on other sites More sharing options...
per1os Posted July 3, 2007 Share Posted July 3, 2007 www.php.net/session by using session. Quote Link to comment Share on other sites More sharing options...
jscix Posted July 3, 2007 Share Posted July 3, 2007 You could use sessions obviously like frost said, or you could just add a get variable into the url echo('<a href="?c=' . $c = $c + 10 . '&post_value_identifier=post_values_you_want_to_keep>Next</a>'); $keptmypostvalue = ($_GET['post_value_identifier']); Quote Link to comment Share on other sites More sharing options...
envexlabs Posted July 3, 2007 Author Share Posted July 3, 2007 hey, thanks for the replies. i'm still having problems, when i click on either button, the page refreshes with the new $c value, but doesn't execute the mysql string. here is the code: $c = 0 + $_GET[c]; $search = $_POST[search]; $table = $_POST[search_param]; $have_submitted = $_POST[have_submitted]; //saves the POST value if(isset($_GET[s])) { $search = $_GET[s]; }else{} //search if(isset($have_submitted)) { //HAS SUBMITTED A SEARCH $info = perform_search($search, $table, $c); //creates the next and previous buttons to only show 10 messages if($c == 0) { echo('Previous'); echo(" | "); echo('<a href="?c=' . $c = $c + 10 . '&s=' . $search . '">Next</a>'); } else{ echo('<a href="?c=' . ($c - 10) . '&s=' . $search . '">Previous</a>'); echo(" | "); echo('<a href="?c=' . ($c + 10) . '&s=' . $search . '">Next</a>'); } //loops out all the entries while($info = mysql_fetch_row($search_query)) { echo '<div class="entry">'; echo '<h2>' . $info[1] . ' ' . $info[2] . '</h2>'; //name echo '<h4>'. $info[3] .', '. $info[4] .', Ontario</h4>'; echo '<div class="bluebox">'; echo '<div class="info_nav"> ' . toggle_info() . ' <div class="square"><img src="images/icons/phone.gif" height="16px" width="16px" alt="" title="Phone Number" /> <p>(807) <!--format_phone(204, $info[5])--> '. $info[5] . '</p></div> <div class="square"><a href=""><img src="images/icons/map.gif" height="16px" width="16px" alt="" title="View Map" /></a></div> <div class="square"><a href="http://www.vantagestudios.ca"><img src="images/icons/monitor_go.gif" height="16px" width="16px" alt="" title="Goto Website" /></a></div> <div class="square"><a href=""><img src="images/icons/email_go.gif" height="16px" width="16px" alt="" title="Send Email" /></a></div> </div></div>'; //navigation echo '<div id="info' . $info[0] . '" style="display: none; width: 510px;">'; echo '<div class="infoimages"> <a href="http://maps.google.com/maps?f=q&hl=en&geocode=&q='. $info[3] .',+'. $info[4] .',+Ontario" title="See a Map"><img src="images/map.gif" alt="Map" title="See a Map" /> <p><a href="http://maps.google.com/maps?f=q&hl=en&geocode=&q='. $info[3] .',+'. $info[4] .',+Ontario" title="See a Map">See a Map</p></a> <a href="images/ad.jpg" rel="lightbox" title=""><img src="images/ad_small.jpg" alt="Map" title="View Advertisement" /></a> <p><a href="images/ad.jpg" rel="lightbox" title="">View Advertisement</a></p> </div>'; echo '<div class="infotext">'; echo "<h3>(807) " . $info[5] . "</h3>"; //phone echo '<div class="addy">'; echo '<p><strong>' . $info[1] . ' ' . $info[2] . '</p></strong>'; //name echo "<p>" . $info[3] . "</p>"; //address echo "<p>" . $info[4] . ", Ontario</p>"; //city echo "<p>P8N 3G2</p>"; echo '</div>'; echo '<div class="extras">'; echo "<p><strong>Fax:</strong> (807) " . $info[9] . "</p>"; //fax echo '<p><strong>Website:</strong> <a href="http://www.vantagestudios.ca" title="Visit Website">www.vantagestudios.ca</a></p>'; echo '<p><strong>E-mail:</strong> <a href="mailto:test@test.com" title="Send an E-mail">test@test.com</a></p>'; echo '</div>'; //echo "<p>" . format_phone(204, $info[5]) . "</p>"; echo '</div>'; echo '</div>'; echo '</div>'; } }else{ //HAVEN'T SUBMITTED A SEARCH } 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.