Zend - The PHP Company




Tables

Add Code


Table Creator  

Type: code fragment
Added by: DerTom
Entered: 03/03/2003
Last modified: 03/12/2002
Rating: - (fewer than 3 votes)
Views: 5215
Creating a Table with $x cols per row


?>
</table>
<?

$b 
113 //numbers to count for
$i 0// incrementor
$z 4// how much cols ?
?>
<table>
<?
    
while($i $b)
        {
            if(
$i == || $i == $a)
                {
                    echo 
"<tr>";
                    
$a $a $z// the beginning ist always $a + cols per row or zero
                    
$e $a 1// the end ist always $a - 1 ;
                    
if ($e $b// if the end ist geater then our count 
                        
{
                            
$e $b 1//we make $b - 1 and thats the end tag
                        
}
                }    
                
                echo 
"<td> ".$i." </td>";
            
            if (
$i == $e
                {
                    echo 
"</tr>";
                }
            
$i++;
        }
?>
</table>
<?


Usage Example




Rate This Script





Search



This Category All Categories