We are a start-up company setup by young enterpreneurs from India and Singapore. We provide complete single point service to all those who want to make their presence on world wide web.

Tabulating MySQL Result Code Snippet!

This code block can be used to display mysql query result in a tabular format. It has been tested by WebSri and found to be working fine.

<?php
$query="select * from table_name";
$result=mysql_query($query);
echo "<table border=1>";
echo "<tr>";
for($i=0;$i<mysql_num_fields($result);$i++)
{
echo "<th>";
echo mysql_field_name($result, $i);
echo "</th>";
}

while($row=mysql_fetch_row($result))
{
echo "<tr>";
for($j=0;$j<$i;$j++)
{
echo "<td>";
echo $row[$j];
echo "</td>";
}
echo "</tr>";
}
echo "</tr>";
echo "</table>";

?>