hane Posted February 9, 2009 Share Posted February 9, 2009 I've got drop down boxes that visitors select to see the items that they want. After selection the selected option gets displayed. I need help with the paging and sort by options coz if i sort or page I loose the selected items. The working code can be viewed at http://www.hefty.co.za. Sorting and paging is not yet enabled. Let me know if you need my code. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/144446-solved-keep-query-data-after-reload-help-please-newbie/ Share on other sites More sharing options...
hane Posted February 10, 2009 Author Share Posted February 10, 2009 Can someone just point me in the right direction PLEASE Quote Link to comment https://forums.phpfreaks.com/topic/144446-solved-keep-query-data-after-reload-help-please-newbie/#findComment-758704 Share on other sites More sharing options...
prahlad Posted February 10, 2009 Share Posted February 10, 2009 I have same problem. Quote Link to comment https://forums.phpfreaks.com/topic/144446-solved-keep-query-data-after-reload-help-please-newbie/#findComment-758705 Share on other sites More sharing options...
gunabalans Posted February 10, 2009 Share Posted February 10, 2009 can you elabrate what you want exactly so that i can help you Quote Link to comment https://forums.phpfreaks.com/topic/144446-solved-keep-query-data-after-reload-help-please-newbie/#findComment-758721 Share on other sites More sharing options...
hane Posted February 10, 2009 Author Share Posted February 10, 2009 When the options that the visitors selected is displayed and they want to sort the records by using the sort by drop down or they go to page 2 I loose the records that were displayed so I end up with sorry no records found. Here is the code that displays the records <?php $cat=$_POST['cat']; $subcat=$_POST['subcat']; $area=$_POST['area']; if ($subcat != "1") { $result = mysql_query("SELECT * FROM c_listing INNER JOIN c_company ON c_listing.c_company_id = c_company.c_company_id WHERE c_subcategory_id=$subcat AND area_id=$area"); if ($area !="1") { $result = mysql_query("SELECT * FROM c_listing INNER JOIN c_company ON c_listing.c_company_id = c_company.c_company_id WHERE area_id=$area"); } else { $result = mysql_query("SELECT * FROM c_listing INNER JOIN c_company ON c_listing.c_company_id = c_company.c_company_id WHERE c_subcategory_id=$subcat"); } } else { $result = mysql_query("SELECT * FROM c_listing INNER JOIN c_company ON c_listing.c_company_id = c_company.c_company_id WHERE area_id=$area"); if ($area !="1") { $result = mysql_query("SELECT * FROM c_listing INNER JOIN c_company ON c_listing.c_company_id = c_company.c_company_id WHERE area_id=$area"); } else { $result = mysql_query("SELECT * FROM c_listing INNER JOIN c_company ON c_listing.c_company_id = c_company.c_company_id INNER JOIN c_subcategory ON c_listing.c_subcategory_id = c_subcategory.c_subcategory_id WHERE c_category_id=$cat"); } } ?> <?php $count=0; while($row = mysql_fetch_array($result)) { echo "<table border='0' width='100%'> "; echo "<tr>"; echo "<td rowspan='4'>"; echo "<a href='classifieds/" . $row['c_item_ref'] . ".jpg'><img src='classifieds/" . $row['c_item_ref'] . ".jpg' width='150'></a>"; echo "</td>"; echo "<th>Description</th>"; echo "<th align='right'>Price: R " . $row['c_item_price'] . "</th>"; echo "<tr>"; echo "<td colspan='2'>" . $row['c_item_description'] . "</td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan='2'><b>Contact:</b> " . $row['c_company_contact_detail'] . "</td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan='2'>"; echo "<b>Email: </b>"; echo "<a href='mailto:" . $row['c_company_email'] . "?subject=Listing on Hefty Description: " . $row['c_item_description'] . " Price: R " . $row['c_item_price'] . "'>" . $row['c_company_email'] . "</a></td>"; echo "</tr>"; echo "<tr><td colspan='3' id='break'> </td></tr>"; $count++; } if ($count==0) { echo 'Sorry no record was found.Please search again'; } echo "</table>"; mysql_close($con); ?> Quote Link to comment https://forums.phpfreaks.com/topic/144446-solved-keep-query-data-after-reload-help-please-newbie/#findComment-758725 Share on other sites More sharing options...
hane Posted February 10, 2009 Author Share Posted February 10, 2009 The paging and sort by code is not included Quote Link to comment https://forums.phpfreaks.com/topic/144446-solved-keep-query-data-after-reload-help-please-newbie/#findComment-758726 Share on other sites More sharing options...
gevans Posted February 10, 2009 Share Posted February 10, 2009 If you need to keep track of these; $cat=$_POST['cat']; $subcat=$_POST['subcat']; $area=$_POST['area']; Add them to your URL; $link = '<a href="directory/your-page.php?cat=$cat&subcat=$subcat&area=$area">your link</a>' Quote Link to comment https://forums.phpfreaks.com/topic/144446-solved-keep-query-data-after-reload-help-please-newbie/#findComment-758805 Share on other sites More sharing options...
premiso Posted February 10, 2009 Share Posted February 10, 2009 Fixed the code above to have proper syntax, here is correct example: $link = '<a href="directory/your-page.php?cat=' . $cat . '&subcat=' . $subcat . '&area=' . $area . '">your link</a>'; And this should be using "$_GET" not $_POST, since variables appeneded to an array is "GET"ting the data, when it is in a form and method="post" it is "posting" the data. $cat=$_GET['cat']; $subcat=$_GET['subcat']; $area=$_GET['area']; Quote Link to comment https://forums.phpfreaks.com/topic/144446-solved-keep-query-data-after-reload-help-please-newbie/#findComment-758890 Share on other sites More sharing options...
hane Posted February 10, 2009 Author Share Posted February 10, 2009 Thanks I just came to let you know that I changed the $_POST to $_GET and I'm now just sorting out the kinks Quote Link to comment https://forums.phpfreaks.com/topic/144446-solved-keep-query-data-after-reload-help-please-newbie/#findComment-758902 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.