Forum Moderators: coopster
if ( $price >= "$100" ) && ( $price <= "$250" ) echo "$item<br> "; else echo " ";
Obviously if I set my query to
$query = "SELECT * FROM products WHERE price > '$100' AND price < '$250' ORDER BY id ASC";
it works. Can anyone point me in the right direction?
Thanks.
if ( $price >= "$100" ) && ( $price <= "$250" )
this will actually try to resolve the $ sign and think those are vars, try changing the double quotes around those to single quotes and see what happens
if ( $price >= '$100' ) && ( $price <= '$250' )
the other thing I wonder, is the $ actually in the column? It could produce some strange results as that makes it a string comparison as opposed to a numeric one.
If I use just a simple if statement such as
if ($price >= '100') echo "$item"<br> "; else echo " ";
it works just fine. But as soon as I add in the
&& ($price <= '250')
it doesn't. This happened whether the $ was in the column or not.
sorry my fault hadn't had my first coffee yet, now I've had 2 we're good to go
it's your parentheses, thr grouping is messed up, though you still need to leave those as single quotes as well
if ( $price >= '$100' ) && ( $price <= '$250' )
you need to contain all of that in your if so you need an extra set
if (($price >= '$100') && ($price <= '$250'))