if...else within while statement...
Posted: Thu Sep 15, 2011 3:44 pm
I can't get an if...else construct to execute within a while statement. Here is the code with the suspect code commented out. The code works as is but if I try uncommenting the if...else php returns a blank page. Thanks in advance for your assistance.
$r_n = 1;
while ($row = mysql_fetch_assoc($result))
{
// if ($r_n <= 9)
// {
echo "<br />",'Record:',$r_n," ",'Name: ',$row['First name'];
echo ' ';
echo $row['Last name'];
echo ' ';
echo 'Phone: ',$row['Phone'];
echo ' ';
echo 'Email: ',$row['Email'];
echo ' ';
$r_n++;
// else
// echo "<br />",'Record:',$r_n," ",'Name: ',$row['First name'];
// echo ' ';
// echo $row['Last name'];
// echo ' ';
// echo 'Phone: ',$row['Phone'];
// echo ' ';
// echo 'Email: ',$row['Email'];
// echo ' ';
// $r_n++;
// }
}
$r_n = 1;
while ($row = mysql_fetch_assoc($result))
{
// if ($r_n <= 9)
// {
echo "<br />",'Record:',$r_n," ",'Name: ',$row['First name'];
echo ' ';
echo $row['Last name'];
echo ' ';
echo 'Phone: ',$row['Phone'];
echo ' ';
echo 'Email: ',$row['Email'];
echo ' ';
$r_n++;
// else
// echo "<br />",'Record:',$r_n," ",'Name: ',$row['First name'];
// echo ' ';
// echo $row['Last name'];
// echo ' ';
// echo 'Phone: ',$row['Phone'];
// echo ' ';
// echo 'Email: ',$row['Email'];
// echo ' ';
// $r_n++;
// }
}