Hey, Im having some issues with my code. I’m trying to produce a table based on the input of the x and y axis. I am able to get the information to show using for loops but the final formula only shows up on one line.
This is the formula i used to calculate the data meant to be in the table:
[code=php]number_format(($j/pow(($i/100),2)),3)
The formula works well but all the results appear on the last row instead of across the table.
Here’s my main code:
[code=php]
<?php
$min_weight = 60;
$max_weight = 90;
$min_height = 140;
$max_height = 170;
echo ‘<!DOCTYPE html>
<head>
<title>Task 1</title>
<style>
body {
background-color: blue;
}
</style>
</head>
<body>
<table border= “1” align= “center” style=”width:600px;”>
<tr>
<th>Height ⇢ </br> Weight ⇣</th>’;
for($i=$min_height; $i<=$max_height; $i=$i+5){
echo ‘<th>’ . $i . ‘</th>
‘;
}
echo'</tr>’;
for ($j=$min_weight; $j<=$max_weight; $j= $j+5) {
echo ‘<tr>
<th>’ . $j . ‘</th>
‘;
}
for($i=$min_height; $i<=$max_height; $i=$i+5){
for ($j=$min_weight; $j<=$max_weight; $j= $j+5) {
echo ‘<td>’ . number_format(($j/pow(($i/100),2)),3) . ‘</td>
‘;
}
}
echo ‘
</tr>
</tr>
</table>
</body>
‘;
?>