dachshund Posted February 1, 2010 Share Posted February 1, 2010 hi, i'm trying to determine if $rows['views'] is bigger than 100. i have $100 = ($rows['views'] > '100'); but that's wrong. any help please? Quote Link to comment https://forums.phpfreaks.com/topic/190547-if-bigger-than-100/ Share on other sites More sharing options...
beansandsausages Posted February 1, 2010 Share Posted February 1, 2010 if($rows['views'] > 100 ) { echo " Do some thing "; } else { echo " do some thng else "; } like that? Quote Link to comment https://forums.phpfreaks.com/topic/190547-if-bigger-than-100/#findComment-1005009 Share on other sites More sharing options...
KevinM1 Posted February 1, 2010 Share Posted February 1, 2010 Remember - quotes denote strings (text). To use numbers, simply write them without quotes. Quote Link to comment https://forums.phpfreaks.com/topic/190547-if-bigger-than-100/#findComment-1005010 Share on other sites More sharing options...
dachshund Posted February 1, 2010 Author Share Posted February 1, 2010 i don't want it to be an if statement. just $100 = i tried without quotes but it still doesnt work. Quote Link to comment https://forums.phpfreaks.com/topic/190547-if-bigger-than-100/#findComment-1005011 Share on other sites More sharing options...
Zane Posted February 1, 2010 Share Posted February 1, 2010 variables can't begin with a number for one. and secondly... try this $if100 = ($rows['views'] > 100) ? "Greater than 100" : "Not greater than 100"; Quote Link to comment https://forums.phpfreaks.com/topic/190547-if-bigger-than-100/#findComment-1005013 Share on other sites More sharing options...
taquitosensei Posted February 1, 2010 Share Posted February 1, 2010 what's with the $if and $100 you can't begin a variable with a number. I also doubt you want a variable $if100. why don't you tell us what you're actually trying to accomplish. That would help. Quote Link to comment https://forums.phpfreaks.com/topic/190547-if-bigger-than-100/#findComment-1005026 Share on other sites More sharing options...
Jezza Posted February 1, 2010 Share Posted February 1, 2010 $var = ($rows['views'] > 100)?true:false; BAM hehe. If the statement in the brackets is true return true, otherwise false. Avoid using numbers at the start of variables and you're fine. Hope it helps. this might help to understand this syntax. Also when saying (greater than '100') don't use the quotes, treat it as a number. echo "Hey, ".(($rows['views']>100)?"It's greater":"It's not greater")." and bye."; Quote Link to comment https://forums.phpfreaks.com/topic/190547-if-bigger-than-100/#findComment-1005028 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.