mysqli:循环数据显示到页面
2011-11-14 20:49
183 查看
mysqli:循环数据显示到页面
连接数据库smarty_fenye 数据表tbl_product
mysqli-----连接对象
mysqli_result----select结果集对象
mysqli_stmt----预处理对象
一:连接数据库mysqli
$mysqli=new mysqli(“localhost”,”root”,”123”,”smarty_fenye”);
二:发送多条语句
$sql=”set names gbk;select * from tbl_product;select name price tbl_product”;
三:循环显示
if($mysqli->multi_query($sql)){
do{
if($result=$mysqli->store_result()){
while($row=$result->fetch_row()){
foreach($row as $value){
echo $value."<br>";
}
}
echo "<br>";
//返回总行数
echo "总行数:".$result->num_rows;
echo "<br>";
echo "总列数:".$result->field_count;
echo "<br>";
echo $result->current_field."当前列";
echo "<br>";
@ $result->field_seek(1);
echo $result->current_field."当前列";
echo "<br>";
$a=$result->fetch_field();
echo "名称1:".$a->name;
echo "<br>";
@ $result->field_seek(2);
echo $result->current_field."当前列";
echo "<br>";
$b=$result->fetch_field();
echo "名称2:".$b->name;
echo "<br>";
}
}while($mysqli->next_result());
}
连接数据库smarty_fenye 数据表tbl_product
mysqli-----连接对象
mysqli_result----select结果集对象
mysqli_stmt----预处理对象
一:连接数据库mysqli
$mysqli=new mysqli(“localhost”,”root”,”123”,”smarty_fenye”);
二:发送多条语句
$sql=”set names gbk;select * from tbl_product;select name price tbl_product”;
三:循环显示
if($mysqli->multi_query($sql)){
do{
if($result=$mysqli->store_result()){
while($row=$result->fetch_row()){
foreach($row as $value){
echo $value."<br>";
}
}
echo "<br>";
//返回总行数
echo "总行数:".$result->num_rows;
echo "<br>";
echo "总列数:".$result->field_count;
echo "<br>";
echo $result->current_field."当前列";
echo "<br>";
@ $result->field_seek(1);
echo $result->current_field."当前列";
echo "<br>";
$a=$result->fetch_field();
echo "名称1:".$a->name;
echo "<br>";
@ $result->field_seek(2);
echo $result->current_field."当前列";
echo "<br>";
$b=$result->fetch_field();
echo "名称2:".$b->name;
echo "<br>";
}
}while($mysqli->next_result());
}
相关文章推荐
- JSP中如何 循环显示 数据库中的数据到list.jsp页面 (转载)
- JSP中如何 循环显示 数据库中的数据到list.jsp页面 (转载)
- JSP中如何 循环显示 数据库中的数据到list.jsp页面 (转载)
- 页面循环里把一个记录数据多行显示
- Jsp实现页面forEach循环遍历多条数据的显示和后台对应数据的获取(strurs1)实现
- Jsp实现页面forEach循环遍历多条数据的显示和后台对应数据的获取(strurs1)实现
- ajax 页面部分先显示图片后出数据
- ASP.NET中使用WebService异步加载数据显示到页面
- android下PDF格式的地图数据的显示------超大PDF页面显示策略(二)
- java web 页面不显示当前绑定数据
- 将数据库里面的数据遍历出来显示在jsp页面
- ajax接收后台数据在html页面显示
- jsp页面显示数据库的数据信息表
- OAF学习笔记-18- Update后页面显示不是最新的数据的解决方法
- html 页面调用js链接并显示数据
- 2017精华版:jquery 中 ajax,后台获取数据库json数据,显示在html页面 02
- cakephp 数据库数据页面显示
- Web页面实现后台数据处理进度与剩余时间的显示
- C# 中的Winform 动态显示当前数据循环情况
- Jsp中forEach循环List显示数据列表