Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have been at this for hours please help. This is what I have. <!doctype html>

ID: 3542449 • Letter: I

Question

I have been at this for hours please help. This is what I have.

<!doctype html>  
<html lang="en">
<head>  
<meta charset="utf-8">

<title>PHP Looping Structures</title>  

</head>
<body>
<div id="container">
<?php

echo "<table border=2 width=50%>";

for ($row = 1; $row <= 4; $row++ ) {   
  echo "<tr> ";
  echo "<td  >".$row."</td> ";
  
   for ( $column= 2; $column <= 3; $column++ ) {
  
        echo "<td >".$column."</td> ";
    }//close inner loop

   echo "</tr> ";
} //close outer loop

echo "</table> ";
?>
</div>
</body>

</html>  

Here is the assignment:

Using a PHP looping structure, create an HTML table.                 

                    The table is to have four rows, three cells per row.                 

                    Each cell is to have the following characteristics:                 

                    Add comments to significant sections of your script to describe the purpose of your code.                 

                    Some Hints:
                    * use a separate counter to keep track of the number of rows
                    * use the modulus operator to set the background color.
                    * use a CSS class to change the background color of the alternating rows.

Explanation / Answer

HI,


Change your code like this... Hope it Helps :)


<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">

<title>PHP Looping Structures</title>

</head>
<body>
<div id="container">
<?php


echo "<table border=2>";


for ($row = 1; $row <= 4; $row++ ) {


echo "<tr > ";

if($row%2==0)

{

echo "<td width=100 bgcolor=lightblue align=center>".$row."</td> ";

}

else

{

echo "<td width=100 align=center>".$row."</td> ";

}


for ( $column= 2; $column <= 3; $column++ )

{

if($row%2==0)

{

echo "<td width=100 bgcolor=lightblue align=center>".$column."</td> ";

}

else

{

echo "<td width=100 align=center>".$column."</td> ";

}

}//close inner loop



echo "</tr> ";

} //close outer loop

echo "</table> ";

?>
</div>
</body>

</html>



Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote