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

Help me compile html and php code: <html> < head> < meta charset=\"utf-8\"> < ti

ID: 3809993 • Letter: H

Question

Help me compile html and php code:

<html>

< head>

< meta charset="utf-8">

< title>PHPTable </title>

< style>

   table, th, td{

    border: 1px solid #333;

   }

< /style>

< /head>

< body>

<?php

$rad = 2.65;

$cir = $rad * 2 * pi();

$area = pow($rad, 2) * pi();

$l=4.2;$b=5.6;

               

$area1=$l*$b;

$cir1=2*($l+$b);

$bs=10.2;

$h=5.4;

$area2=0.5*$bs*$h;

$m=sqrt(pow($b,2),pow($h,2));

$cir2=$m+$h+$b;

$ba=5.3;

$area3=pow($ba,2);

$cir3=4*$ba;

?>

echo

<table>

<tr>

    <th>circle</th>

    <th>triangle</th>

    <th>Right triangle</th>

    <th>square</th>

< /tr>

<tr><td>Circle</td><td><img src="http://www.abcteach.com/free/c/circlergb.jpg" width="10"

height="10"/></td></tr>

<tr>

    <td>$cir</td>

    <td>$area</td>

   </tr>

<tr><td>triangle</td><td><img src="www.kidsmathgamesonline.com/images/pictures/shapes/triangle.jpg" width="10"

height="10"/></td></tr>

   <tr>

    <td>$cir1</td>

    <td>$area1</td>

   </tr>

<tr><td>right triangle</td><td><img src="http://www.manyagroup.com/blog/wp-content/uploads/2015/10/triangle2.jpg" width="10"

height="10"/></td></tr>

   <tr>

    <td>$cir2</td>

    <td>$area2</td>

</tr>

<tr><td>Square</td><td><img src="https://www.colourbox.com/preview/19044060-square-format-photo-frame-photo-border.jpg" width="10"

height="10"/></td></tr>

<tr>

    <td>$cir3</td>

    <td>$area3</td>

   </tr>

</table>'

< /body>

< /html>

Explanation / Answer

Hi Student,

I have corrected the code. Please remember some points below while developing HTML or PHP code.

1. There should not be any space inside the html tags.
   for ex. Wrong: < html> correct: <html>

2. It is recommended to have a corresponding close tag for an open tag in HTML

3. In the image tag, you have to give complete http url. URL shoudl start with http://

4. You can print php variables in html tags like below.
   <? php echo $cir ;?>
  
5. You should have php or xampp installed in your computer to open the php files. I recommend to install xampp, it has so many inbuilt features. After installing xampp, you should place your .php file inside the "HTDocs" folder. Make sure that tomcat server is started. Then you can your php script using browser http://localhost/excersise.php

Here is modifed PHP code.

<html>
<head>
<meta charset="utf-8">
<title>PHPTable </title>
<style>
table, th, td{
border: 1px solid #333;
}
</style>
</head>
<body>
<?php
$rad = 2.65;
$cir = $rad * 2 * pi();
$area = pow($rad, 2) * pi();
$l=4.2;$b=5.6;

$area1=$l*$b;
$cir1=2*($l+$b);
$bs=10.2;
$h=5.4;
$area2=0.5*$bs*$h;
$m=sqrt(pow($b,2));
$cir2=$m+$h+$b;
$ba=5.3;
$area3=pow($ba,2);
$cir3=4*$ba;

?>

<table>
<tr>
<th>circle</th>
<th>triangle</th>
<th>Right triangle</th>
<th>square</th>
</tr>
<tr><td>Circle</td><td><img src="http://www.abcteach.com/free/c/circlergb.jpg" width="20" height="20"/></td></tr>
<tr>
<td> <?php echo $cir ;?> </td>
<td><?php echo $area ;?></td>
</tr>
<tr><td>triangle</td><td><img src="http://www.kidsmathgamesonline.com/images/pictures/shapes/triangle.jpg" width="20" height="20"/></td></tr>
<tr>
<td><?php echo $cir1 ;?></td>
<td><?php echo $area1 ;?></td>
</tr>
<tr><td>right triangle</td><td><img src="http://www.manyagroup.com/blog/wp-content/uploads/2015/10/triangle2.jpg" width="20" height="20"/></td></tr>
<tr>
<td><?php echo $cir2 ;?></td>
<td><?php echo $area2 ;?></td>
</tr>
<tr><td>Square</td><td><img src="https://www.colourbox.com/preview/19044060-square-format-photo-frame-photo-border.jpg" width="20" height="20"/></td></tr>
<tr>
<td><?php echo $cir3 ;?></td>
<td><?php echo $area3 ;?></td>
</tr>
</table>
</body>
</html>