经过几个小时的修补,我似乎无法弄清楚。我在数据库中有一个表,其中包含一个充满值的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]
}
}
最佳答案
您可以像这样在查询中使用IN
子句,而不是每次都遍历和发出mysql查询:
$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
}