>Hiya,
>
>How can i draw a new <tr> AFTER FIVE  <td> in the following loop
>
>(i want to echo the records in 5 columns width tables whatever the number
of
>records will be fetched)
>
>..
>echo '<table>';
>
>while ($myrow = mysql_fetch_array($sql))
>{
>echo $myrow[0];
>}
>echo '</table>';
>
>
>regards

$i = 1;
echo '<table border=1>' . "\n";
echo '<tr>' . "\n";

while ($myrow = mysql_fetch_array($sql)){

    echo '<td>' . $myrow[0]. "</td>\n";

    if ($i % 5 == 0){
        echo "</tr>\n<tr>";
    }

$i++;
}

$odd = ($i - 1)  % 5;
if ($odd){
    echo '<td colspan="'.$odd.'">&nbsp;</td>' . "\n";
}
echo '</tr>' . "\n";
echo '</table>' . "\n";


adrian

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to