Can someone explain a simple solution using MySQL and PHP how to check if an email has been sent already, stopping duplicates for users.
I have a basic script, but it's not working for some re开发者_Go百科ason - http://pastebin.com/k7yiQahb It inserts into the table the following:
feed_id, recipient_id, issent
0, 0, Y
Regards
Why not create a column issent
of type enum(Yes,No) DEFAULT 'No'
in the table recipients
instead of a separate table.
Then, when email is sent successfully, run this:
update `recipients` set issent = 'Yes' where id = $id
And when you are fetching email recipients in the beginning, just do:
select email, suburb, id FROM recipients where issent = 'No' GROUP BY id ORDER BY id DESC
This will give you only unsent addresses.
[EDIT]: If there are multiple recipients, you can run first query like this:
update `recipients` set issent = 'Yes' where id IN (3,4,5,6)
精彩评论