Page 1 of 2 12 LastLast
Results 1 to 25 of 49
  1. #1
    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')";
    	}
    This code is used in two files which can be downloaded here.

    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.

  2. #2
    Can you post the sql table structure export? For testing purposes. Think I figured it out.

  3. #3
    Join Date
    Jul 2009
    Posts
    70
    I really hope so Sam!
    Please see the sql file here.
    Thanks,

  4. #4
    Small bug I just noticed btw:

    Code:
    SELECT * FROM properties WHERE  propertytype in ('NULL')
    If someone doesn't select a type, wouldn't you just want to search all properties? The way this works, it will select no properties based on this condition.

  5. #5
    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

  6. #6
    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?

  7. #7
    Quote Originally Posted by kendalbren View Post
    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.
    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?

    Quote Originally Posted by kendalbren View Post
    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?
    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.

  8. #8
    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.

  9. #9
    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!

  10. #10
    If space required is 200 - 2500 why should it return a property with size greater than 2500?

  11. #11
    Quote Originally Posted by kendalbren View Post
    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!
    Oh okay. Well in that case there's no point in using between, right? It should just be greater than the minimum?

  12. #12
    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.

  13. #13
    But if max space is 2500 it shouldn't, since prop id 96 has a size of 2596, right?

  14. #14
    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!

  15. #15
    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

  16. #16
    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!

  17. #17
    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.

  18. #18
    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.

  19. #19
    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?

  20. #20
    Quote Originally Posted by kendalbren View Post
    Space from should be not greater than the maximum size. Space to should not be less than the minimum size.
    But the space (2596) is greater than the maximum size (2500) in this case?

  21. #21
    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!

  22. #22
    Join Date
    Jan 2010
    Location
    good ole UK
    Posts
    341
    Quote Originally Posted by kendalbren View Post
    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.
    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.

  23. #23
    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!

  24. #24
    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.

  25. #25
    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)

Page 1 of 2 12 LastLast

Similar Threads

  1. Need nginx + php expert to solve weird problem
    By marmoset01 in forum Systems Management Requests
    Replies: 7
    Last Post: 05-18-2010, 04:57 PM
  2. $50 reward to whoever can solve this PHP Form MIME Header problem:
    By vonaras in forum Employment / Job Offers
    Replies: 18
    Last Post: 04-04-2006, 11:37 PM
  3. need someone to solve small php problem
    By Hostlead in forum Employment / Job Offers
    Replies: 2
    Last Post: 08-03-2005, 05:22 PM
  4. PHP and Ticketsmith. Can you solve my problem?
    By Domenico in forum Hosting Software and Control Panels
    Replies: 10
    Last Post: 10-24-2001, 10:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •