Things you should know.
1. Basic PHP
2. Understanding of scripting.
If...Else statements
1. If...Else statements are used if you want your script/scripts to do something based on a variable.
CODE
<?php
if (condition)
code to be done if condition is true;
else
code to be done if condition is false;
?>
if (condition)
code to be done if condition is true;
else
code to be done if condition is false;
?>
2. With that, you're probably a bit still confused as to what it's doing, I was too at first. Look at the next code for a better explanation. This is if there was a form prior to this page, that form, asking what is 4+5, their answer being $a.
CODE
<?php
$a = 4+5;
if($a == 9)
echo "You are correct, 4+5=9!";
else
echo "You are not correct, please go back and try again.";
?>
$a = 4+5;
if($a == 9)
echo "You are correct, 4+5=9!";
else
echo "You are not correct, please go back and try again.";
?>
3. If the persons answer is 9, the page will say 'You are correct, 4+5=9!', if not, it will say 'You are not correct, please go back and try again.'
4. Now, the If...elseif...else statement.
CODE
<?php
$d=date("D");
if ($d=="Fri")
echo "Have a nice weekend!";
elseif ($d=="Mon")
echo "Have a nice week!";
else
echo "Have a nice day!";
?>
$d=date("D");
if ($d=="Fri")
echo "Have a nice weekend!";
elseif ($d=="Mon")
echo "Have a nice week!";
else
echo "Have a nice day!";
?>
5. If the day is Friday, it says 'Have a nice weekend!', if the day is Monday, it will say 'Have a nice week!', and if the day is not Friday or Monday, it says 'Have a nice day!'.
That's it for If...Else statements, next lesson would be on Arrays, but I don't like Arrays so it'll be made later on, next Lesson will be on functions.

