In a general web site, we will usually see that many of the tables in the database in the browser are in the table, the first to feel very magical, but careful thinking is not too complicated, since you can dql and DML general return, the form of return should not be a problem, but, One thing is that it's wrong to design a script on the client to implement the problem. Even if it can be implemented is very complex, so, only on the server side to consider, think about the way to solve the problem, that is, when the return of the print table tags and corresponding attributes and attribute values, although this approach does not seem reasonable, But this is also the most effective way. The specific code is as follows:
<?php//display table data in tables, common style function showtable ($table _name) {$conn =mysql_connect ("localhost
"," root "," Toor ");
if (! $conn) {echo "Connection failed";
} mysql_select_db ("Test", $conn);
mysql_query ("Set names UTF8");
$sql = "SELECT * from $table _name";
$res =mysql_query ($sql, $conn); $rows =mysql_affected_rows ($conn);//Get the number of rows $colums =mysql_num_fields ($res);//Get the number of columns echo "Test Database". $table _name "."
Table of all user data as follows:<br/> "; echo "Total". $rows. " Line ". $colums."
Column <br/> ";
echo "<table style= ' border-color: #efefef; ' border= ' 1px ' cellpadding= ' 5px ' cellspacing= ' 0px ' ><tr>";
for ($i =0; $i < $colums; $i + +) {$field _name=mysql_field_name ($res, $i);
echo "<th> $field _name</th>";
echo "</tr>";
while ($row =mysql_fetch_row ($res)) {echo "<tr>";
For ($i =0 $i < $colums; $i + +) {echo <td> $row [$i]</td>];
echo "</tr>";
echo "</table>"; } showtable ("Test1");