PHPmysqli的 其他函数 从数据库中读出数据并且打印出来

 1 <?php
 2 
 3 // 认识其他mysqli其他函数
 4 header( 'Content-Type:text/html;charset=utf-8 ');
 5 require 'prepareSrarment.php';
 6 $mysqli=new mysqli("localhost", "root", "root", "user1", 3306);
 7 $mysqli->set_charset("utf8");
 8 $sql="select *from user1";
 9 $res=$mysqli->query( $sql);
10 echo $res->field_count;//列数
11 echo  $res->num_rows;//行数
12 //从$res取出
13 echo "<table border='1px solid #fcc'><tr>";
14 while ($field=$res->fetch_field()){
15     echo "<th>{$field->name}</th>";
16 
17     
18 }
19 echo "</tr>";
20 echo "<tr>";
21 while ($row=$res->fetch_row())
22 {
23     foreach ( $row as $key=>$val)
24     {
25         echo "<td>{$val}</td>";
26     }
27     echo "</tr>";
28 }
29 
30 
31 
32 echo "</table>";
33 
34 ?>
原文地址:https://www.cnblogs.com/tl542475736/p/3428587.html