HookedOnWeb Posted March 15, 2006 Share Posted March 15, 2006 I am trying to echo a when a range of number are between a starting and stopping number. For example:When I is >= 12 and <=18 echo II am having trouble writing the conditional statement. Checking for one number is easy but when I try to check if the number is between two numbers, it cannot get it to work.I am try:$start = 12;$end = 18;for ($i=1; $i >= $start && $today <= $end; $1++) { echo $i . "<br>";}What I want to happen is to print out are the numbers 12 - 18 down the screen.I am using the FOR loop to test the condition. What I am really trying to do is add a IF condition to the code I have already written, for example:if ($today >= $start && $today <= $end) { echo "The range is between " . $i . "<br>";}This echo is just there for the example I am actually printing out something else, this way it was easier to read.I know this is basic but I am learning. Quote Link to comment Share on other sites More sharing options...
saiko Posted March 15, 2006 Share Posted March 15, 2006 && equals and|| equals or$start = 12;$end = 18;if(($today >= $start) && ($today <= $end)) {echo "The range is between " . $i . "<br>";}hope it helps :D Quote Link to comment Share on other sites More sharing options...
HookedOnWeb Posted March 16, 2006 Author Share Posted March 16, 2006 Yes that helped and the code is now working the way I wanted to, thanks! Quote Link to comment 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.