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
https://forums.phpfreaks.com/topic/95370-simple-condition-checking-help/
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'"; 
    } 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.