Like Twey said, this should be done in SQL. However, I don't really like the SQL he used. I would write the query like this.
Code:
DELETE table_1 WHERE friend_email IN (SELECT email FROM table_2)
Just a matter of preference really.
If you really wanted to do this in PHP. You would need to store all the results from query in an array. Then, loop through the second set of results and check the match.
PHP Code:
$names2 = Array();
while($row2 = mysql_fetch_array($get_names2_res)){
$names2[] = $rows2['email'];
}
while($row = mysql_fetch_array($get_names_res)) {
$friend_email = stripslashes($row['friend_email']);
for($i=0;$i<count($names2);$i++){
$users_email = stripslashes($names2[$i]);
if ($users_email == $friend_email) {
echo"Yeah we found that name ($users_email)";
}
}
}
However, this should NOT be done with PHP.
Bookmarks