经过几个小时的修修补补,我似乎无法弄明白这一点。我在数据库中有一个表,其中包含一个充满值的CSV字段。使用php explode函数后,我留下了一个数组。
$emailarray = list($email) = explode(",", $csv);
while($arrayreadable = mysql_fetch_array($emailarray,$emailcount[0])){
$makefeed = mysql_query("SELECT email,name FROM $statusdatabase WHERE email = $arrayreadable[`0`]'");
while ($friendfeedget = mysql_fetch_assoc($makefeed)) {
[Code for what I want the loop to do]
}
}
答案 0 :(得分:1)
不是每次循环并发出mysql查询,而是可以在查询中使用IN
子句,如下所示:
$emailarray = list($email) = explode(",", $csv);
$emails = implode(',', $emailarray);
$makefeed = mysql_query("SELECT email,name FROM $statusdatabase WHERE email IN ('".$emails."')");
while ($friendfeedget = mysql_fetch_assoc($makefeed)) {
// code
}