Jump to content

Help with IF statements and the || and && conditions


HookedOnWeb

Recommended Posts

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 I

I 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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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