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

 <?php

 // 认识其他mysqli其他函数
header( 'Content-Type:text/html;charset=utf-8 ');
require 'prepareSrarment.php';
$mysqli=new mysqli("localhost", "root", "root", "user1", 3306);
$mysqli->set_charset("utf8");
$sql="select *from user1";
$res=$mysqli->query( $sql);
echo $res->field_count;//列数
echo $res->num_rows;//行数
//从$res取出
echo "<table border='1px solid #fcc'><tr>";
while ($field=$res->fetch_field()){
echo "<th>{$field->name}</th>"; }
echo "</tr>";
echo "<tr>";
while ($row=$res->fetch_row())
{
foreach ( $row as $key=>$val)
{
echo "<td>{$val}</td>";
}
echo "</tr>";
} echo "</table>"; ?>
上一篇:基于css3的文字3D翻转特效


下一篇:网络编程Socket之RST详解