Use the MySQL extension class to take the database data out and put it on the table.

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.