DMXzone Paginator PHP Support Product Page
This topic is locked
Answered
Using Paginator with Form Results[SOLVED]
Asked 08 Jul 2009 03:54:32
1
has this question
08 Jul 2009 03:54:32 Tom Carr posted:
Hello!I am using Paginator for PHP on a real estate website where a user selects his criteria from a form, and then submits it. The resulting page has a table of all the matching homes for sale, and I am using Paginator to break the results set down.
The problem is that when clicking on the link to go to the second or subsequent pages, the Paginator querystring overwrites the parameters coming from the form and thus the second page returns all records, not just the ones that matched the original query.
Do I need to save off the original query results somewhere and append them to the Paginator links? If so, can you give me some direction?
Thanks,
Tom
Edited by - Tom Carr on 08 Jul 2009 03:54:57
Replies
Replied 08 Jul 2009 05:10:29
08 Jul 2009 05:10:29 Tom Carr replied:
OK - I think I answered my own question.
If I use the GET method on the form, it works fine and the Paginator extension appends the page number to the current querystring.
But it if use the POST method, the parameters are gone.
Thanks!
If I use the GET method on the form, it works fine and the Paginator extension appends the page number to the current querystring.
But it if use the POST method, the parameters are gone.
Thanks!
Replied 14 Jul 2011 06:32:15
14 Jul 2011 06:32:15 liz banbury replied:
Hi there... I'm having exactly the same problem for a very similar type of website. However even after I change the form to use $_GET , when I click the next page, for me no results show..when I then go back to the first page (or #1) then of course no results still show and I have to submit the search criteria all over again?
Any help would be great!
Many thanks
Any help would be great!
Many thanks
Replied 14 Jul 2011 15:37:50
14 Jul 2011 15:37:50 liz banbury replied:
Hi.
I have managed to get it working with a simple form just by changing POST to GET everywhere. However having big problems with more complex forms which have dynamic fields and dropdowns etc etc.
Here is the form code:
I have changed all to $_GET but the pagination does not do anything.
Any help would be really appreciated..
Thanks
I have managed to get it working with a simple form just by changing POST to GET everywhere. However having big problems with more complex forms which have dynamic fields and dropdowns etc etc.
Here is the form code:
<form action="propertylisting_sell.php" method="get" name="proptype" class="proparea" id="proptype"> <fieldset> <legend class="proparea"> Property Search <label for="prop_cat"></label> <input name="prop_cat" type="hidden" class="maintext" id="prop_cat" value="Sell" readonly="readonly" /></legend> <table width="228" border="0" align="center" cellpadding="1" cellspacing="1" class="maintext"> <tr> <td colspan="2"><select name="prop_type" onchange="display(this,'Private Apartments','Landed Property', 'Hdb Flat', 'Commercial', 'Hudc Apartments');"> <option selected="selected">Please Select</option> <option value="Private Apartments">Private Apartments</option> <option value="Landed Property">Landed Property</option> <option value="Hdb Flat">Hdb Flat</option> <option value="Commercial">Commercial </option> <option value="Hudc Apartments">Hudc Apartments </option> <option value="invisible">Invisible</option> </select></td> </tr> <tbody id="Private Apartments" style="display: none;"> <tr> <td colspan="2"><select name="prop_saletype1" id="prop_saletype1"> <?php do { ?> <option value="<?php echo $row_prop_apartment['prop_saletype']?>"><?php echo $row_prop_apartment['prop_saletype']?></option> <?php } while ($row_prop_apartment = mysql_fetch_assoc($prop_apartment)); $rows = mysql_num_rows($prop_apartment); if($rows > 0) { mysql_data_seek($prop_apartment, 0); $row_prop_apartment = mysql_fetch_assoc($prop_apartment); } ?> </select></td> </tbody> <tbody id="Landed Property" style="display: none;"> <tr> <td colspan="2"> <select name="prop_saletype2" id="prop_saletype2"> <?php do { ?> <option value="<?php echo $row_prop_landed['prop_saletype']?>"><?php echo $row_prop_landed['prop_saletype']?></option> <?php } while ($row_prop_landed = mysql_fetch_assoc($prop_landed)); $rows = mysql_num_rows($prop_landed); if($rows > 0) { mysql_data_seek($prop_landed, 0); $row_prop_landed = mysql_fetch_assoc($prop_landed); } ?> </select> </td> </tbody> <tbody id="Hdb Flat" style="display: none;"> <tr> <td colspan="2"> <select name="prop_saletype3" id="prop_saletype3"> <?php do { ?> <option value="<?php echo $row_prop_hdb['prop_saletype']?>"><?php echo $row_prop_hdb['prop_saletype']?></option> <?php } while ($row_prop_hdb = mysql_fetch_assoc($prop_hdb)); $rows = mysql_num_rows($prop_hdb); if($rows > 0) { mysql_data_seek($prop_hdb, 0); $row_prop_hdb = mysql_fetch_assoc($prop_hdb); } ?> </select> </td> </tbody> <tbody id="Commercial" style="display: none;"> <tr> <td colspan="2"> <select name="prop_saletype4" id="prop_saletype4"> <?php do { ?> <option value="<?php echo $row_prop_commercial['prop_saletype']?>"><?php echo $row_prop_commercial['prop_saletype']?></option> <?php } while ($row_prop_commercial = mysql_fetch_assoc($prop_commercial)); $rows = mysql_num_rows($prop_commercial); if($rows > 0) { mysql_data_seek($prop_commercial, 0); $row_prop_commercial = mysql_fetch_assoc($prop_commercial); } ?> </select> </td> </tbody> <tbody id="Hudc Apartments" style="display: none;"> <tr> <td colspan="2"> <select name="prop_saletype5" id="prop_saletype5"> <?php do { ?> <option value="<?php echo $row_prop_hudc['prop_saletype']?>"><?php echo $row_prop_hudc['prop_saletype']?></option> <?php } while ($row_prop_hudc = mysql_fetch_assoc($prop_hudc)); $rows = mysql_num_rows($prop_hudc); if($rows > 0) { mysql_data_seek($prop_hudc, 0); $row_prop_hudc = mysql_fetch_assoc($prop_hudc); } ?> </select> </td></tr> </tbody> <tr></table> <table width="228" border="0" align="center" cellpadding="1" cellspacing="1"> <td width="78" class="maintext">Tenure:</td> <td width="143" class="maintext"><label for="prop_tenure"></label> <select name="prop_tenure" id="prop_tenure"> <?php do { ?> <option value="<?php echo $row_rs_tenure['prop_tenure']?>"><?php echo $row_rs_tenure['prop_tenure']?></option> <?php } while ($row_rs_tenure = mysql_fetch_assoc($rs_tenure)); $rows = mysql_num_rows($rs_tenure); if($rows > 0) { mysql_data_seek($rs_tenure, 0); $row_rs_tenure = mysql_fetch_assoc($rs_tenure); } ?> </select> </td> </tr> <tr> <td class="maintext">District Zone:</td> <td class="maintext"> <select name="district_zone" id="district_zone"> <?php do { ?> <option value="<?php echo $row_rs_district['district_zone']?>"><?php echo $row_rs_district['district_zone']?></option> <?php } while ($row_rs_district = mysql_fetch_assoc($rs_district)); $rows = mysql_num_rows($rs_district); if($rows > 0) { mysql_data_seek($rs_district, 0); $row_rs_district = mysql_fetch_assoc($rs_district); } ?> </select> </td> </tr> <tr> <td class="maintext">Price:</td> <td class="maintext"><label for="prop_pricemin"></label> <input name="prop_pricemin" type="text" id="prop_pricemin" value="<?php if(isset($_GET['prop_pricemin']))echo $_GET['prop_pricemin']; else{ echo '0';}?>" size="15" maxlength="15" /> (min) </td> </tr> <tr> <td class="maintext"> </td> <td class="maintext"><label for="prop_pricemax"></label> <input name="prop_pricemax" type="text" id="prop_pricemax" value="<?php if(isset($_GET['prop_pricemax'])) echo $_GET['prop_pricemax']; else {echo '1000000';}?>" size="15" maxlength="15" /> (max)</td> </tr> <tr> <td class="maintext">Bedrooms:</td> <td class="maintext"> <select name="prop_bedroom" id="prop_bedroom"> <option value="<?php echo $_GET['prop_bedroom']; ?>" selected="selected"><?php echo $_GET['prop_bedroom']; ?></option> <option value="Any">Any</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5+">5+</option> </select> </td> </tr> <tr> <td class="maintext">Bathrooms:</td> <td class="maintext"> <select name="prop_bathroom" id="prop_bathroom"> <option value="<?php echo $_GET['prop_bathroom']; ?>" selected="selected"><?php echo $_GET['prop_bathroom']; ?></option> <option value="Any">Any</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5+">5+</option> </select> </td> </tr> <tr> <td class="maintext"> Search:</td> <td align="left" class="maintext"> <input name="submit" type="submit" class="maintext" id="submit" value="SEARCH" /> </td> </tr> </table> </fieldset> </form>
I have changed all to $_GET but the pagination does not do anything.
Any help would be really appreciated..
Thanks
Replied 14 Jul 2011 15:38:33
14 Jul 2011 15:38:33 liz banbury replied:
Oh and here is the code from the recordset query:
$query_rs_search = "SELECT property_details.prop_id, property_details.add_house, property_details.prop_saletype, property_details.prop_bedroom, property_details.prop_bathroom, property_details.prop_type, property_details.prop_cat, property_details.prop_sold, property_details.prop_price, property_details.screenpath, property_details.image_main, property_tenure.prop_tenure, property_districts.district_zone FROM property_districts, property_details, property_tenure WHERE property_districts.district_zone = property_details.add_zone AND property_tenure.prop_tenure = property_details.prop_tenure AND property_details.prop_cat = 'Sell' AND property_details.prop_sold = 'Active' AND add_date > DATE_ADD(current_date, INTERVAL -21 DAY) AND property_details.prop_price >= '$_GET[prop_pricemin]' AND property_details.prop_price <= '$_GET[prop_pricemax]' AND property_details.prop_bathroom >= '$lcl_prop_bathroom1' AND property_details.prop_bathroom <= '$lcl_prop_bathroom2' AND property_details.prop_bedroom >= '$lcl_prop_bedroom1' AND property_details.prop_bedroom <= '$lcl_prop_bedroom2' AND property_districts.district_zone LIKE '$lcl_district_zone' AND property_tenure.prop_tenure = '$_GET[prop_tenure]' AND ( (property_details.prop_type = '$_GET[prop_type]' AND property_details.prop_saletype = '$_GET[prop_saletype1]' ) OR (property_details.prop_type = '$_GET[prop_type]' AND property_details.prop_saletype = '$_GET[prop_saletype2]' ) OR (property_details.prop_type = '$_GET[prop_type]' AND property_details.prop_saletype = '$_GET[prop_saletype3]' ) OR (property_details.prop_type = '$_GET[prop_type]' AND property_details.prop_saletype = '$_GET[prop_saletype4]' ) OR (property_details.prop_type = '$_GET[prop_type]' AND property_details.prop_saletype = '$_GET[prop_saletype5]' ) ) ORDER BY property_details.prop_tenure, property_details.prop_type, property_details.prop_price ASC";
Replied 15 Jul 2011 10:12:00
15 Jul 2011 10:12:00 Miroslav Zografski replied:
Hello Liz,
can you please send the page in question to my e-mail:
can you please send the page in question to my e-mail:
Replied 16 Jul 2011 03:57:46
16 Jul 2011 03:57:46 liz banbury replied:
Hi
By building up the form from scratch I can see it works up until the point I have more complex if statements in
The pagination only seems to work if the query can be contained within the recordset query which is generated.
There must be someway to include fields with these if statements?
Many thanks for the help :-)
liz
By building up the form from scratch I can see it works up until the point I have more complex if statements in
if ($_POST[district_zone] == "All") { $lcl_district_zone = "%"; } else { $lcl_district_zone = $_POST[district_zone]; } if ($_POST[prop_bedroom] == "Any") { $lcl_prop_bedroom1 = 0; $lcl_prop_bedroom2 = 100; } elseif ($_POST[prop_bedroom] == "5+") { $lcl_prop_bedroom1 = 5; $lcl_prop_bedroom2 = 100; } else { $lcl_prop_bedroom1 = $_POST[prop_bedroom]; $lcl_prop_bedroom2 = $_POST[prop_bedroom]; } if ($_POST[prop_bathroom] == "Any") { $lcl_prop_bathroom1 = 0; $lcl_prop_bathroom2 = 100; } elseif ($_POST[prop_bathroom] == "5+") { $lcl_prop_bathroom1 = 5; $lcl_prop_bathroom2 = 100; } else { $lcl_prop_bathroom1 = $_POST[prop_bathroom]; $lcl_prop_bathroom2 = $_POST[prop_bathroom]; }
The pagination only seems to work if the query can be contained within the recordset query which is generated.
There must be someway to include fields with these if statements?
Many thanks for the help :-)
liz
Replied 18 Jul 2011 08:13:24
18 Jul 2011 08:13:24 liz banbury replied:
Hello
I've fixed it and all working now.
The pagination part was fine and was just a distraction. It was actually the MaxRows section from the recordset that needed to be doing more!
Many thanks liz
I've fixed it and all working now.
The pagination part was fine and was just a distraction. It was actually the MaxRows section from the recordset that needed to be doing more!
Many thanks liz
Replied 18 Jul 2011 08:48:59
18 Jul 2011 08:48:59 Miroslav Zografski replied:
Hello Liz,
I'm glad you have narrowed it down. In fact using a differet than the regular recordset requires consideration of some variables set by the extension as it was in your case.
I'm glad you have narrowed it down. In fact using a differet than the regular recordset requires consideration of some variables set by the extension as it was in your case.