Can someone help with the following code. Im simply trying to display the total number of values between the starting num and ending num. ie: If the start is 200 and end is 205, I need to print 200,201,202,203,204 and 205 on the screen. Please assist with the following code
<?php
$con=mysql_connect('localhost','root') or die ("Server connection failure!");
$db=mysql_select_db('regional_data',$con) or die ("Couldn't connect the database");
$SQL="SELECT startnum, endnum FROM newchk";
$run=mysql_query($SQL,$con) or die ("SQL Error");
$nor=mysql_num_rows($run);
while ($rec = mysql_fetch_array($run))
{
for($i=$rec['startnum']; $i=$rec['endnum']; $i++)
{
echo $i;
}
}
?>
You missed the
<in yourforloop condition.Note: the code dose not contain comma in the output, it will produce
200201202203204205in the screen.If you want to print comma concentrated string, you could do: