URGENT! Write a valid HTML + PHP Page that will count numbers from 1 to 1,000,000?

i. Display every 10th number in the series in Bold
ii. Display every 3rd number in the series in Italics
iii. Bonus: Underline every Prime number in this series.

See my code. Please correct me. Urgent

<?php  
     for ($i = 1; $i <= 1000000; ++$i) {

     $mod3 = $i % 3;
     $mod10 = $i % 10;
     $str = '';
     if (!$mod3) {
       $str = '<p style="color: red;"><u>$i</u></p>';
     }
     if (!$mod10) {
       $str .= '<p style="color: blue;"><u>$i</u></p>';
     }
     if ($mod3 && $mod10) {
       $str .= '<p style="color: purple;"><em>$i</em></p>';
     }
     echo $str, "\n"; // gives: the color is red, blue, purple
    }
?>

I know that $i is a variable. I tried other means but didnt get the good results. Please assist on time.
Correct me and paste your code here.

Regards.

<b> This in bold</b> <u>This is underline</u> <i>This is italic</i>
Put the above tags in your code
Why have you used
$mod5 = $i %5
t should be
$mod10 = $i%10

Thank you. I have adjust the code a little, See Below. Kindly help me check. @camperextraordinaire, Pls be a good teacher. I know you can assist. I will appreciate.

<b> This in bold</b> 
<u>This is underline</u> 
<i>This is italic</i>
<?php  
     for ($i = 1; $i <= 1000000; ++$i) {

     $mod3 = $i % 3;
     $mod10 = $i % 10;
     $str = '';
     if (!$mod3) {
       $str = '<p style="color: red;"><u>$i</u></p>';
     }
     if (!$mod10) {
       $str .= '<p style="color: blue;"><u>$i</u></p>';
     }
     if ($mod3 && $mod10) {
       $str .= '<p style="color: purple;"><em>$i</em></p>';
     }
     echo $str, "\n"; // gives: the color is red, blue, purple
    }
?>

What of this way?

$str = ‘

$i

’;
$str .= “red”;
echo $str; // gives: the color is red

What of this way

$str = '

$i

';

$str .= "red">$i

';

echo $str; // gives: the color is red

```

$str = '<p style="color";

$str .= "red";

echo $str; // gives: the color is red

...
$str = '<p style="the color is"><u>$i</u></p>';
$str .= "red";

echo $str; // gives: the color is red

Okay, but how do you concatenate a string in PHP?

@camperextraordinaire
@PriyaMe
@Steffan153

Please check if the code is ok.

<b> This in bold</b> 
<u>This is underline</u> 
<i>This is italic</i>
<?php  
     for ($i = 1; $i <= 1000000; ++$i) {

     $mod3 = $i % 3;
     $mod10 = $i % 10;
     $str = '';
     if (!$mod3) {
       $str = '<p style="the color is"><u>$i</u></p>' red;
     }
     if (!$mod10) {
       $str .= '<p style="the color is"><u>$i</u></p>' blue;
     }
     if ($mod3 && $mod10) {
       $str .= '<p style="the color is"><em>$i</em></p>' purple;
     }
     echo $str, "\n"; // gives: the color is red, blue, purple
    }
?>

ok. I will adjust it now. Thanks

It is showing Syntax error, unexpected T_STRING

$str = '<p style="the color is"><u>$i</u></p>' red;

@camperextraordinaire
@PriyaMe
@Steffan153

Pls help me out

Pls help me out. I’m waiting

@camperextraordinaire

It did not showing any error again BUT I want you to help me confirm it and revert back.

<b> This in bold</b> 
<u>This is underline</u> 
<i>This is italic</i>
<?php  
     for ($i = 1; $i <= 1000000; ++$i) {

     $mod3 = $i % 3;
     $mod10 = $i % 10;
     $str = '';
     if (!$mod3) {
       $str = '<p style="color=red"><u>$i</u></p>';
     }
     if (!$mod10) {
       $str .= '<p style="color=blue"><u>$i</u></p>';
     }
     if ($mod3 && $mod10) {
       $str .= '<p style="color=purple"><em>$i</em></p>';
     }
     echo $str, "\n"; // gives: the color is red, blue, purple
    }
?>

If it so urgent you are in the wrong place, this is not an instant chat, people have lifes and come here to help when they can.


I don’t know much of php, but it seems to me you are italicing both each 3rd and 10th number. you are not using the bold tag anywhere (<b> or <strong> depending on how new is the html you need to use)

Instead you are underlining everything. Ignore the thing about prime numbers if you don’t know what they are, be sure to implement the first two points first, then you can try to implement the bonus part

Thanks. I have corrected it as you stated above. Check the code below:

<b>This is bold</b> 
<u>This is underline</u> 
<i>This is italic</i>
<?php  
     for ($i = 1; $i <= 1000000; ++$i) {

     $mod3 = $i % 3;
     $mod10 = $i % 10;
     $str = '';
     if (!$mod3) {
       $str .= '<p style="color=red"><i>$i</i></p>';
     }
     if (!$mod10) {
       $str .= '<p style="color=blue"><b>$i</b></p>';
     }
     if ($mod3 && $mod10) {
       $str .= '<p style="color=purple"><u>$i</u></p>';
     }
     echo $str, "\n"; // gives: the color is red, blue, purple
    }
?>

You use colons in CSS.

You’re still not concatenating anything.
Did you notice that dot over there?

You need to use that to concatenate strings.

yeah, no… ignore the part about prime numbers, that’s not how you calculate prime numbers. Ignore that part.

For now just make sure that every 30th number is both bold and italic, not underlined (because it is not a prime number)

once that works you can think about prime numbers, not before, as that needs a different kind of calculations

Pls show me how to. Give sample

Try to use a dot to concatenate strings. Syntax is $something . "someotherstring".