Results 1 to 25 of 49
-
04-02-2011, 05:15 AM #1Junior Guru Wannabe
- Join Date
- Jul 2009
- Posts
- 70
$20 to the first who can solve my PHP problem
Hi guys,
I posted this on another thread but it didn't get resolved.
I'll happily pay $20 to the first person who can solve this issue for me.
I've designed a property search website (please see here) and outsourced the coding. Everything seems to be working fine except one small part - searching by property sizes.
The properties have a minimum size and a maximum size (for example 500 sq ft and 2,596 sq ft). On the search page, the user enters a minimum size and a maximum size (for example 200 sq ft - 2,500 sq ft). In this case, the property above should appear in the list but it doesn't show up. My code is below:
Code:if ($_POST["go"]!=""){ if ($ptype0=='' && $ptype1=='' && $ptype2=='' && $ptype3=='') { $sql = "SELECT * FROM properties WHERE propertytype in ('NULL') AND ((size BETWEEN $minsize AND $maxsize) and (peoplesize BETWEEN $minppl AND $maxppl) and (price BETWEEN $minprice AND $maxprice))"; } else { $sql = "SELECT * FROM properties WHERE propertytype not in ('$ptypea','$ptypeb','$ptypec','$ptyped') and ((size BETWEEN $minsize AND $maxsize) and (peoplesize BETWEEN $minppl AND $maxppl) and (price BETWEEN $minprice AND $maxprice))"; } if ($ttype=="both"){ $sql = $sql . " AND tenuretype in ('$ttype','let','buy')"; } if ($ttype=="let"){ $sql = $sql . " AND tenuretype in ('$ttype','both')"; } if ($ttype=="buy"){ $sql = $sql . " AND tenuretype in ('$ttype','both')"; }
As I understand it, using BETWEEN should include this property. Could someone fix this for me?
I'll pay whoever can fix this through PayPal.
Thanks.
-
04-02-2011, 05:22 AM #2Disabled
- Join Date
- Jul 2009
- Posts
- 2,195
Can you post the sql table structure export? For testing purposes. Think I figured it out.
-
04-02-2011, 05:31 AM #3Junior Guru Wannabe
- Join Date
- Jul 2009
- Posts
- 70
I really hope so Sam!
Please see the sql file here.
Thanks,
-
04-02-2011, 05:38 AM #4Disabled
- Join Date
- Jul 2009
- Posts
- 2,195
Small bug I just noticed btw:
Code:SELECT * FROM properties WHERE propertytype in ('NULL')
-
04-02-2011, 05:40 AM #5Disabled
- Join Date
- Jul 2009
- Posts
- 2,195
I have it selecting 29 properties based on these values:
$minsize = 500;
$maxsize = 2596;
$maxppl = 100000000000;
$minppl = 0;
$maxprice = 1000000000;
$minprice = 0;
Everything else is left blank. Does that sound about right?Last edited by Squidix; 04-02-2011 at 05:41 AM. Reason: Errors in numbers
-
04-02-2011, 05:45 AM #6Junior Guru Wannabe
- Join Date
- Jul 2009
- Posts
- 70
To answer your first question - I don't think so. If no property type is selected, it should return 0 properties. All property types are selected by default so this shouldn't be a problem.
To answer your second question - if I enter the min property size as 500 and max property size as 2596 on the site here, I get 29 properties. Does that help?
-
04-02-2011, 05:48 AM #7Disabled
- Join Date
- Jul 2009
- Posts
- 2,195
So that whole conditional there is kind of pointless I guess. Another question:
SELECT * FROM properties WHERE propertytype not in ('$ptypea','$ptypeb','$ptypec','$ptyped')
Why are you using NOT IN here? Shouldn't it be IN, since these are the types they selected?
So that's wrong then? You're expecting more properties that aren't in the list?
Give me the exact search parameters you are using, and the ID of the property you are expecting to be returned.
-
04-02-2011, 05:57 AM #8Junior Guru Wannabe
- Join Date
- Jul 2009
- Posts
- 70
To be honest Sam, I'm not sure why NOT IN is being used. I outsourced the coding and the guy is unavailable now.
The search parameters I'm using are
Town: Empty
County: Empty
Property Type: All
Price: 0 - 895000
Space required: 200 - 2500
Number of people: 0 - maxiumum
This should return property ID 96 but it doesn't. It should return this property because the maximum size of the property is 2596 sqft.
-
04-02-2011, 05:59 AM #9Junior Guru Wannabe
- Join Date
- Jul 2009
- Posts
- 70
I know this is confusing but maybe thinking of the properties as houses will help. Imagine someone searches for number of bedrooms and enters 3. All 4 bedroom houses should be returned as there are more than 3 bedrooms.
Hope that helps - it really confuses me!
-
04-02-2011, 06:00 AM #10Disabled
- Join Date
- Jul 2009
- Posts
- 2,195
If space required is 200 - 2500 why should it return a property with size greater than 2500?
-
04-02-2011, 06:01 AM #11Disabled
- Join Date
- Jul 2009
- Posts
- 2,195
-
04-02-2011, 06:13 AM #12Junior Guru Wannabe
- Join Date
- Jul 2009
- Posts
- 70
I guess space from should be not greater than the maximum size. Space to should not be less than the minimum size.
I hope that helps. Very confused now!
That would mean that property ID 96 is returned in the example above.
-
04-02-2011, 06:24 AM #13Disabled
- Join Date
- Jul 2009
- Posts
- 2,195
But if max space is 2500 it shouldn't, since prop id 96 has a size of 2596, right?
-
04-02-2011, 06:30 AM #14Junior Guru Wannabe
- Join Date
- Jul 2009
- Posts
- 70
If price from is entered as 2500, property id 96 should show because its maximum size is 2596. 2500 is not greater than 2596 so it should be shown.
Hope that helps!
-
04-02-2011, 06:32 AM #15Disabled
- Join Date
- Jul 2009
- Posts
- 2,195
I thought we were talking about maximum space? The space for prop id 96 in the database you gave me is 2596.
I'm just trying to clarify why a search for space greater than 200 but less than 2500 would include 2596?
Space required: 200 - 2500
-
04-02-2011, 06:39 AM #16Web Hosting Master
- Join Date
- Feb 2006
- Location
- Kusadasi, Turkey
- Posts
- 3,379
Sorry to sound dumb, but you are aware that 2596 is even larger than your maximum search parameter of 2500? So it should NOT be returned.
█ Fraud Record - Stop Fraud Clients, Report Abusive Customers.
█ Combine your efforts to fight misbehaving clients.
█ HarzemDesign - Highest quality, well designed and carefully coded hosting designs. Not cheap though.
█ Large and awesome portfolio, just visit and see!
-
04-02-2011, 06:42 AM #17Disabled
- Join Date
- Jul 2009
- Posts
- 2,195
Either way, I have the script working to the point where if you enter:
$minsize = 500;
$maxsize = 2596;
$maxppl = 100000000000;
$minppl = 0;
$maxprice = 1000000000;
$minprice = 0;
You get 47 properties. Property 96 is included in these results.
-
04-02-2011, 06:49 AM #18Junior Guru Wannabe
- Join Date
- Jul 2009
- Posts
- 70
Using my theory above, if space to is entered as 2500, property 96 should still show as the minmum size of the property is 500. 2500 is not less than 500.
I know it's confusing but I think the best way to think of it is in terms of bedrooms.
I'm pretty sure it will work is we use:
Space from should be not greater than the maximum size. Space to should not be less than the minimum size.
-
04-02-2011, 06:51 AM #19Disabled
- Join Date
- Jul 2009
- Posts
- 2,195
Then what's the point in entering 2500 if you're going to return properties larger than 2500? Why even have a minimum and maximum, why not just a minimum?
-
04-02-2011, 06:53 AM #20Disabled
- Join Date
- Jul 2009
- Posts
- 2,195
-
04-02-2011, 07:08 AM #21Web Hosting Master
- Join Date
- Feb 2006
- Location
- Kusadasi, Turkey
- Posts
- 3,379
I think I somewhat understand your idea of the space required.
If someone needs 200-2500 sqft of space, it's OK for them to get a property that's 3000 sqft size?
If someone needs 200-2500 sqft of space, it's NOT OK for them to get a property that's 2000 sqft size, because they may need 2500?█ Fraud Record - Stop Fraud Clients, Report Abusive Customers.
█ Combine your efforts to fight misbehaving clients.
█ HarzemDesign - Highest quality, well designed and carefully coded hosting designs. Not cheap though.
█ Large and awesome portfolio, just visit and see!
-
04-02-2011, 07:09 AM #22Web Hosting Guru
- Join Date
- Jan 2010
- Location
- good ole UK
- Posts
- 341
I 'll try and play intermediate here without interupting @kendalbren
what is saying is in your query here you have a maximum size value required as 2500, yet property 96 has a size of 2596 which is larger than the required max value of 2500 and therefore should not be shown...
EDIT:
just seen the post above and if thats the case then your correct but again as he said before why do you need the range of min/max when you could just use min and return all properties that have more space than the minimum requirement? and just a thought but why would I pay for a property with 40000sqft when you only require a maximum of 5000sqft..?Last edited by Driver01; 04-02-2011 at 07:13 AM.
█ I H4t3 l33T, l33T i5 4 l053r5!
██
███
████ Personally I'm always ready to learn, although I do not always like being taught.
-
04-02-2011, 07:11 AM #23Junior Guru Wannabe
- Join Date
- Jul 2009
- Posts
- 70
Harzem, Sam, you're both correct. This is really confusing, isn't it?
The bottom line is:
If someone needs 200-2500 sqft of space, it's OK for them to get a property that's 3000 sqft size?
If someone needs 200-2500 sqft of space, it's NOT OK for them to get a property that's 2000 sqft size, because they may need 2500?
How can that be achieved? My head hurts!
-
04-02-2011, 07:16 AM #24Disabled
- Join Date
- Jul 2009
- Posts
- 2,195
Bottom line, why not just return anything greater than the minimum? Based on what I can understand here, the 2500 entered on the search form is rendered useless.
-
04-02-2011, 07:17 AM #25Disabled
- Join Date
- Jul 2009
- Posts
- 2,195
If someone searches for a property from 200 to 2500 sq ft, obviously they don't WANT a property that is more than 2500 sq ft (2596 included)
Similar Threads
-
Need nginx + php expert to solve weird problem
By marmoset01 in forum Systems Management RequestsReplies: 7Last Post: 05-18-2010, 04:57 PM -
$50 reward to whoever can solve this PHP Form MIME Header problem:
By vonaras in forum Employment / Job OffersReplies: 18Last Post: 04-04-2006, 11:37 PM -
need someone to solve small php problem
By Hostlead in forum Employment / Job OffersReplies: 2Last Post: 08-03-2005, 05:22 PM -
PHP and Ticketsmith. Can you solve my problem?
By Domenico in forum Hosting Software and Control PanelsReplies: 10Last Post: 10-24-2001, 10:41 AM