PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I'm doing an example out of the book 'php and mysql for web development' and for the life of me I can't seem to pick out the error in this code. The gist of this loop is, it's supposed to fill in the first two table cells with the $distance variable for the first cell and that number diviided by ten for the second.
Here is the code:
<?php
//the first distance cell will be 50
$distance=50;
//while the variable 'distance' is less than 50.
//create table cells and populate them with numbers
//until the number is equal to distance
while ($distance <= 250 )
{
echo "<tr><td bgcolor='#ff4433'>"$distance"</td>";
echo "<td bgcolor='#ff4433'>".$distance/10."</td></tr>";
//distance = distance + 50
$distance+=50;
}
?>
It's only filling the first cells with the actual 'variable name', and the 'variable name/10'. I picked out some errors that were in the code originally, but these problems remain. I am completely befuddled. I have spent some time trting to find a way to get it to function. I would greatly appreciate any help I could get. Thanks.
<?php
//the first distance cell will be 50
$distance=50;
//while the variable 'distance' is less than 50.
//create table cells and populate them with numbers
//until the number is equal to distance
while ($distance <= 250 )
{
echo "<tr><td bgcolor='#ff4433'>";
echo $distance;
echo "</td>";
echo "<td bgcolor='#ff4433'>";
echo $distance/10;
echo "</td></tr>";
//distance = distance + 50
$distance+=50;
}
?>