Hey guys so my task is to print out a volume using a variable with a random number from 1 to 100. If the volume is lesser than 30 it has to print out a text called quiet at a certain size listed in my code, and the same thing with a different text called normal if the volume is lesser than 70. However, when I try to implement the if statements I keep getting a Parse error: syntax error, unexpected 'elseif' (T_ELSEIF) in C:\xampp\htdocs\PracticeLabExam\task3.php on line 17 and don't understand what I am doing wrong
<html>
<title> Task 3 </title>
<style>
p { width: 75%; margin: auto; color:blue; background-color: silver;
padding:20px; }
</style>
<body>
<h1> Task 3: PHP Program #1 </h1>
<?php
$number = mt_rand(1,100);
?>
<p style="text-align: center"> Volume is <?php echo $number; ?></p>
<?php
if($number < 30) {
?> <p style="font-size: 0.5em; text-align: center"> quiet </p>
}
<?php elseif($number < 70 && $number > 30) { ?>
<p style="font-size: 1.25em; text-align: center"> normal </p>
}
<?php else { ?>
<p style="font-size: 3em; text-align: center"> loud </p>
}
</body>
</html>
If I try to change it like this:
<?php
if($number < 30) {
?> <p style="font-size: 0.5em; text-align: center"> quiet </p>
}
<?php if($number < 70 && $number > 30) { ?>
<p style="font-size: 1.25em; text-align: center"> normal </p>
}
<?php if($number >= 70) { ?>
<p style="font-size: 3em; text-align: center"> loud </p>
}
</body>
</html>
I get Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\PracticeLabExam\task3.php on line 27
Please help.