PDA

View Full Version : searchbox_minmax producing incorrect values? - FIXED 1.1.3



grapeape
08-10-2003, 01:33 AM
This problem originally occurred while using version 1.1.0. I didn't know I wasn't using the newest version so I upgraded to version 1.1.2 and tried it again. The problem I describe below was originally written when using 1.1.0 (the generic template). The problem still occurs in 1.1.2 (using the vertical_menu template) except the "step" feature doesn't seem to work now. If the min is 0 and the max is 4, it should list 0,1,2,3,4 in the drop down box but instead just lists 0,4.

1)
At the time of this writing, the "Bedrooms Min/Max" and the "Bathrooms Min/Max" do not display correctly at http://www.open-realty.org/demo/listingsearch.php. The drop down boxes for each min/max display two values and they are both 0. Is this because "agents" input incorrect values into the "beds" and "baths" fields when creating a listing which hosed the min/max calulations?

2)
When testing Open Realty, my database contained three listings (including the default White House listing). The number of bedrooms in the listings were 4, 5, and 10. The number of bathrooms in the listings were 3, 5, and 35. I made the bedrooms and bathrooms searchable (search type: minmax, Step by: 1). On my search page, it allowed me to choose from a minimum of 0 beds and a maximum of 4 beds (it should have been a maximum of 10 beds). Also on my search page, it allowed me to choose from a minimum of 0 baths and a maximum of 3 baths (this should have been a maximum of 35 baths).

Is this a bug or am I configuring something wrong?

I haven't looked at this problem deeply enough yet but could this problem be in the rounding? The $min is calculated like this:

$min = round($conn->GetOne("select max(field_value +0) from " . $config[table_prefix] . "listingsDBElements, " . $config [table_prefix] . "listingsDB where field_name = '$browse_field_name'".$rental_str), -3);

According to http://us3.php.net/manual/en/function.round.php, the "-3" is the precision and a precision of -3 rounds anything under 500 to 0. If I took the -3 out and had the default precision, it fixes my problem (maybe it causes another problem somewhere else?). For the beds example, $min becomes 10 and the $max becomes 4. For the baths example, $min becomes 35 and $max becomes 3. The code in listingsearch.php switches those around so the min and max are correct.

Please let me know if I made a mistake in my analysis or if you have a solution for this problem. Thanks! :D

--------------------------------------
Notes:
For the bedroom calculation:
In template/generic/style.php, in the searchbox_minmax function, $max was equal to 4 and $min was equal to 0

For the bathroom calculation:
In template/generic/style.php, in the searchbox_minmax function, $max was equal to 3 and $min was equal to 0

RealtyOne
08-10-2003, 03:22 AM
Certainly seems to be a problem with the search page on the demo :)

greengiant
08-10-2003, 08:55 AM
Good call, we had the min rounding -3 for price seraches that way you get 10,000 instead of 10,321... Anyways, I will put a if statement in there to handle this. Thanks for the bug report