Wednesday, November 18, 2009

Create Auto Generated Table according to no of record in table

If we want to create table automatic according to no of record come from database;
first we declare how much no of col in table want to display.

<table width="810" border="0" cellspacing="0" cellpadding="0">

<?php

$colNo;

$i=0;

$slectQuery="select title from table";

$Result=mysql_query($selectQuery,$dbc)or die('error in fetch record:-'.mysql_error());


while($row=mysql_fetch_row($Result)){

if($i==0){

echo '<tr>';
}

echo '<td>

$i++;

if($i==$colNo){


echo '</tr>';
$i=0;
}

?>

</table>


No comments:

Post a Comment