Monday, June 28, 2010

Creating a table in for loop each row with 5 column

If Your retrieving a n-number of data from database and wants to display in table like with n*m row*col then this code will be used
$col is number of column's

O/P will be like this

<table border="1px"> ?php $col=5; for ( $i=1; $i<=20; $i++){ if(!($i-1 % $col)){ ?> <tr><?php } ?> <td><?php echo $i; ?></td> <?php if(!($i % $col)){?> </tr> <?php }
} ?> </table>

No comments:

Post a Comment