Reputation: 1
I have the following query :
UPDATE
users AS t
LEFT JOIN (
SELECT
user
FROM
facebook, users
WHERE
facebook.user = users.id
GROUP BY
users.id
) AS m ON
m.user = t.id
SET
t.coins =t.coins+200
WHERE
m.user = t.id
I need help to create a php script which must actually send an email to the users I update the number of coins. The email field is in users table.
Thank you!
Upvotes: 0
Views: 295
Reputation: 3823
Select all rows you need:
SELECT
t.id, t.email
FROM
users AS t
LEFT JOIN (
SELECT
user
FROM
facebook, users
WHERE
facebook.user = users.id
GROUP BY
users.id
) AS m ON
m.user = t.id
WHERE
m.user = t.id
and then update every row in PHP loop where you also can send your mail.
UPDATE
So let imagine $result
is var with result array.
foreach($result as $res){
$sql = 'UPDATE users SET coins = coins+200 WHERE id = '.$res['id'];
mail(/*WITH YOUR PARAMS*/); //email in $res['email'];
}
Upvotes: 1