1<?PHP2 Header("Content-type:text/html;charset=utf-8");3 functionOtherfunction ($dbnamem,$tbname){4 $conn=mysql_connect(' localhost ', ' root ', ') or die(Mysql_error());5 mysql_query("Use".)$dbnamem) or die(Mysql_error());6 mysql_query("Set names UTF8") or die(Mysql_error());7 $sql= "SELECT * from".$tbname;8 $res=mysql_query($sql) or die(Mysql_error());9 //number of rows obtainedTen //$rows = Mysql_affected_rows ($conn); One //$rows = Mysql_num_rows ($res); A $colums=Mysql_num_fields($res); - //Remove the table header - Echo"<table border=1><tr>"; the for($i= 0;$i<$colums;$i++) { - #code ... - $file _name=Mysql_field_name($res,$i); - Echo"<th>$file _name</th> "; + } - Echo"</tr>"; + A //echo "<tr>"; at //Remove line information - while($row=Mysql_fetch_row($res)) { - #code ... - Echo"<tr>";//Loop Output Line - for($i= 0;$i<$colums;$i++) { - #code ... in Echo"<td>$row[$i]</td> ";//Looping output Columns - } to Echo"</tr>"; + } - //echo "</tr>"; the * Echo"</table>"; $ Panax Notoginseng } - $dbnamem= "MySQL"; the $tbname= "User"; +Otherfunction ($dbnamem,$tbname); A the?>
Use the MySQL extension class to take the database data out and put it on the table.