愚蠢的问题... mysql_fetch_array() [英] Dumb Question... mysql_fetch_array()
问题描述
嘿那里
我有一个愚蠢的问题....
让我们说我有一个满是4000的数据库人....我从数据库中选择了一切
:
$ result = mysql_query(" SELECT * FROM People");
我的问题是关于我得到的结果...如果我使用:
while($ row = mysql_fetch_array($ result)){
//在这里做东西
}
之后//在这里做东西已完成(让我们说它有很多东西),并且获取下一行数据的
,是来自数据库的数据行,
或它是来自php变量$ result?
基本上,因为我每行都做了很多事情(即:发送它们
每个电子邮件),我想知道以下代码是否有用/无意义
....
$ x = 1;
while($ row = mysql_fetch_array($ result)){
$电子邮件[$ x] = $ row [''电子邮件''];
$ Name [$ x] = $ row [''Name''];
$ x ++;
}
。 ..然后通过迭代数组来做我的事情
foreach($ Email as $ key => $ value){
/ * do stuff在这里(发送$ Name [$ key]一封信给她的电子邮件地址
$ value)* /
}
这完全是多余的吗?我想这一切都取决于是否
mysql_fetch_array将返回数据库....
基本上我试图避免任何丢失mysql连接的可能性
,因为//在这里做东西花了这么长时间....
提前致谢!
Hey there
I have a dumb question....
Let''s say i have a database full of 4000 people.... I select everything
from the database by:
$result = mysql_query("SELECT * FROM People");
My question is about the results that I get... if I use:
while ($row = mysql_fetch_array($result)) {
//do stuff here
}
after "//do stuff here" is done (and let''s say its a LOT of stuff), and the
next row of data is fetched, is the row of data coming from the database,
or is it coming from the php variable $result?
basically, since i''m doing a LOT of things to each row (ie: sending them
each an email), i was wondering if the following code was helpful/pointless
....
$x = 1;
while ($row = mysql_fetch_array($result)) {
$Email[$x] = $row[''Email''];
$Name[$x] = $row[''Name''];
$x++;
}
... and THEN do my things by iterating through an array
foreach ($Email as $key=>$value) {
/* do stuff here (send $Name[$key] a letter to her email address of
$value) */
}
Is this totally redundant? I guess it all comes down to whether or not
mysql_fetch_array is going back to the database....
Basically I''m attempting to avoid any chance of losing a mysql connection
because the "//do stuff here" is taking so long....
Thanks in advance!
推荐答案
result = mysql_query(" ; SELECT * FROM People");
我的问题是关于我得到的结果...如果我使用:
while(
result = mysql_query("SELECT * FROM People");
My question is about the results that I get... if I use:
while (
row = mysql_fetch_array(
row = mysql_fetch_array(
result)){
//在这里做点什么
}
在" // do stuff here"已完成(让我们说它有很多东西),并且获取下一行数据的
,是来自数据库的数据行,
或它来自php变量
result)) {
//do stuff here
}
after "//do stuff here" is done (and let''s say its a LOT of stuff), and the
next row of data is fetched, is the row of data coming from the database,
or is it coming from the php variable
这篇关于愚蠢的问题... mysql_fetch_array()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!