So I have created a PHP page that will prompt the user to enter 2 Celsius temperatures (start & stop) and a number to increment between the two. Then it loops through the numbers and displays the Fahrenheit conversion of each number base on the increment in a table format. The problem i am currently having is that I am trying to put the table display in a variable so that i can display it below the number inputs but at the moment i am only able to display it above. I think the problem is that the variable isn't recognizing the table because when i try to echo it below it just says "1". I've tried putting the entire table in quotes and a bracket but it is still not working.
Here is the part of the code where the table comes in:
if ($start_error == "" && $stop_error == "" && $inc_error == "") {
$result = print "<table width=\"25%\" border =\"1\" style='border-collapse: collapse'>";
print "<tr><th>Celsius</th>";
print "<th>Fahrenheit</th></tr>";
for ($row=1; $row <= 1; $row++) {
for ($c = $start; $c <= $stop; $c+=$inc) {
print "<tr> \n";
$f = $c * 1.8 +32;
for ($col=1; $col <= 1; $col++) {
print "<td align=\"center\">$c°</td> \n";
print"<td align=\"center\">$f°</td> \n";
}
print "</tr>";
}
print "</table>";
}
}
}
?>
<h2><?php echo $start_error; ?></h2>
<h2><?php echo $stop_error; ?></h2>
<h2><?php echo $inc_error; ?></h2>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" >
Starting Temperature: <input type="text" name="start_number" value="<?php echo $start; ?>" size="5" /><br/>
Stop Temperature: <input type="text" name="stop_number" value="<?php echo $stop; ?>" size="5" /><br/>
Temperature Increment: <input type="text" name="inc_number" value="<?php echo $inc; ?>" size="5" /><br/>
<input type="submit" value="Create Temperature Conversion Table" />
</form>
<?php echo $result; ?>
printfor the return value.