Panjabel Posted July 15, 2007 Share Posted July 15, 2007 <?php $ok = "60"; if ($ok>30) || ($ok<=50){ print "30-50"; } else { print "60-over"; } ?> what is wrong ? Link to comment https://forums.phpfreaks.com/topic/60025-solved-calculating-problem/ Share on other sites More sharing options...
infid3l Posted July 15, 2007 Share Posted July 15, 2007 <?php $ok = 60; if (($ok>30) || ($ok<=50)){ print "30-50"; } else { print "60-over"; } ?> Link to comment https://forums.phpfreaks.com/topic/60025-solved-calculating-problem/#findComment-298539 Share on other sites More sharing options...
Panjabel Posted July 15, 2007 Author Share Posted July 15, 2007 <?php $ok = 60; if ($ok>30) || ($ok<=50){ print "30-50"; } else { print "60-over"; } ?> doesn't work too Link to comment https://forums.phpfreaks.com/topic/60025-solved-calculating-problem/#findComment-298540 Share on other sites More sharing options...
infid3l Posted July 15, 2007 Share Posted July 15, 2007 Sorry, my C programming days kind of blended in with PHP. Look at the modified code above. Link to comment https://forums.phpfreaks.com/topic/60025-solved-calculating-problem/#findComment-298543 Share on other sites More sharing options...
Panjabel Posted July 15, 2007 Author Share Posted July 15, 2007 <?php $ok = 60; if (($ok>30) || ($ok<=50)){ print "30-50"; } else { print "60-over"; } ?> doesn't work too, $ok = 60; so i want it to print out "60-over" but it print out "30-50" what's wrong ? Link to comment https://forums.phpfreaks.com/topic/60025-solved-calculating-problem/#findComment-298545 Share on other sites More sharing options...
infid3l Posted July 15, 2007 Share Posted July 15, 2007 <?php $ok = 60; if (($ok>30) || ($ok<=50)){ print "30-50"; } else { print "60-over"; } ?> doesn't work too, $ok = 60; so i want it to print out "60-over" but it print out "30-50" what's wrong ? Ohh I see. You're using || which means OR. You need to use && (and): <?php $ok = 60; if (($ok>=30) && ($ok<=50)){ print "30-50"; } else { print "60-over"; } ?> Link to comment https://forums.phpfreaks.com/topic/60025-solved-calculating-problem/#findComment-298546 Share on other sites More sharing options...
Panjabel Posted July 15, 2007 Author Share Posted July 15, 2007 Great! Thanks Link to comment https://forums.phpfreaks.com/topic/60025-solved-calculating-problem/#findComment-298547 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.