Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003
    Posts
    2

    Unanswered: Dynamic Query help

    I am building a basic search from to query a rental property database. I have created the following query:

    $query="select id,add1,add2,city,rent,bedroom from $tbl_prop where
    city='$city' and rent <='$rent' and style='$style' and bedroom >= '$bdrm' order by rent";

    The problem is that if the user leaves say the rent dropdown blank then I return 0 results instead of all results regardless of the amount of rent.

    Any ideas on how I can make this happen?

    Thanks
    Lou

  2. #2
    Join Date
    Oct 2003
    Posts
    13

    Thumbs up try this

    use this

    $query="select id,add1,add2,city,rent,bedroom from $tbl_prop where
    city='$city' ";
    if (!empty($rent)){ $query.=" and rent <='$rent' "; }
    .....


    and so on

    Manish Khanna
    manish@i4u.com.au

  3. #3
    Join Date
    Dec 2003
    Posts
    2

    Re: try this

    BINGO....

    Thanks for your help.

    Originally posted by i4u_dev4
    use this

    $query="select id,add1,add2,city,rent,bedroom from $tbl_prop where
    city='$city' ";
    if (!empty($rent)){ $query.=" and rent <='$rent' "; }
    .....


    and so on


Posting Permissions

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