Hi I'm making a quick PHP program that takes in an integer (x) and prints the numbers from 1 to that number.
- If the number is divisible by 3 then print "Hello".
- If the number is divisible by 7 print "World".
- If the number is divisible by 3 & 7, print "Hello World".
The output is nothing.
$var = 0;
if (isset($_POST['submit']))
{
for ($i = 1; $i < $var; $i++)
{
if ($var % 3 == 0)
{
echo 'Hello' . "
";
}
if ($var % 7 == 0)
{
echo 'World'. "
";
}
if (($var % 7 == 0) && ($var % 3 == 0))
{
echo 'Hello World'. "
";
} else {
echo "";
}
}
}