如何通过PHP code和MySQL循环? [英] how to loop through PHP code and MySQL?

查看:113
本文介绍了如何通过PHP code和MySQL循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用PHP的遍历查询,而不是把所有的结果到一个数组,然后循环通过数组

How do I use the PHP loop through the query instead of putting all the result into an array then looping through the array

我用数组和循环的方法是这样的:

The way I use array and loop is like this:

<?php $userInfos = $qry->querySelect( SQL CODE HERE );

  foreach($userInfos as $uInfo)
        {
        $fName = $uInfo['fName'];
        $lName = $uInfo['lName'];
        $gender = $uInfo['gender'];
?>

First name is: <? echo $fName; ?> and Last name is <? echo $lName; ?>.

<?php } ?>

我想知道通过查询PHP回路是如何比好阵更好的洞察力。请重定向我一些示例或可能包括MySQL的code。

I wanted to know better insight on how PHP loop through the query is better than array. Please redirect me to some example or possibly with MySQL code included.

我怎么能转换成以上的PHP code更有效的,如果我拉百万的记录?

How can I convert the above php code to be more efficient if I am pulling millions of record?

太感谢了!

推荐答案

您可以做mysqli_fetch_row一个简单的循环()

You can do a simple loop with mysqli_fetch_row()

http://php.net/manual/en/mysqli- result.fetch-row.php

这篇关于如何通过PHP code和MySQL循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆