I have an array of email addresses. The array variable is called $d_contacts. So what I want to do is go through each email in the array and see if the email exists in a table of a mysql db.
If so, i want to grab some info from the table that corresponds to that email (such as id, firstname, last name). Finally I want to generate a list of these, so I can echo them out in html.
If the email is not in the table, I want to generate a separate list of just the email addresses.
So far I have the following, but can't seem to get it to work. I must be doing something wrong. Can anyone please simplify this for me?
foreach((array)$d_contacts as $d_contact) {
$sql_check = mysql_query("SELECT * FROM members WHERE email='$d_contact' ");
while($row = mysql_fetch_array($sql_check)){
$countrows = mysql_num_rows($check_sql);
if($countrows > 0){
$firstname = $row["firstname"];
$lastname = $row["lastname"];
$outputList_A .= '
<div>
' . $firstname . ' ' . $lastname . '
</div>
';
} else {
$outputList_B .= '
<div>
' . d_contact . '
</div>
';
}
}
}
echo "$outputList_A";
echo "$outputList_B";