Jump to content

Simple condition checking help?


Mr Chris

Recommended Posts

Hi All,

 

I have a very simple piece of condition checking that I’m having trouble with:

 

I only want to use this condition IF $from_price OR $to_price is empty then don't add the below query:

 

    if(!empty($from_price) || ($to_price)) 
    { 
      $add .= " AND price BETWEEN '$from_price' AND '$to_price'";   
    }

 

However, if $from_price has a value and $to_price does not it still outputs this condition (and vice versa).

 

Can anyone help?

 

Thanks

 

 

Link to comment
Share on other sites

Thanks,  Just one more i'm stuck with on a condition check.

 

If $bathroom is not empty and less than 4 otherwise use the other condition

 


    if(!empty($bathrooms) && $bathrooms < '4') 
    { 
      $add .= " AND bathrooms = '$bathrooms'"; 
    } 

    if(!empty($bathrooms) && $bathrooms > '5') 
    { 
      $add .= " AND bathrooms > '5'"; 
    } 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.