0

After several hours of tinkering I cannot seem to figure this out. I have a table in the database which holds a CSV field full of values. After using the php explode function I am left with an array.

$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]

}


}

1 Answer 1

2

Instead of looping through and issuing mysql query each time, you can use the IN clause in your query like this:

$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
}
Sign up to request clarification or add additional context in comments.

2 Comments

For some reason I am unable to get your solution to work. The query works without error but the where seems to not find any matches.
You should specify list of email separated by comma in where clause.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.