Emailing people when there is a new comment
<p>I'm extremely new to PHP and my first project was developing a comment system. So now it is great but I would like to give the commenters the choice to get emails when there is a new comment. First I decide to create another row in my table called:
'email_notifications'. In the submit.php for the comment form.</p>

<p>To email everyone.... I wan't to use:</p>

<pre><code>$emails = mysql_query("SELECT * FROM email_notifications");
while($row=mysql_fetch_assoc($emails)) {
mail($row['email'],'New Comment on...','There was a new comment o....',"From: no-reply@jdrag.x10.mx");
}
</code></pre>

<p>I'm not even sure this would work. But my first concern was that it was going to email people more than once.
Because, if people comment more than once with the same email, wont it just email that email more than once when it goes though the database for all the emails. Thats my big concern. Anyway I could email people when there is a new comment without email people more than once each time there is a new comment. </p>

<p>Summary(what I want to accomplish):</p>

<p><strong>1.</strong> Someone submits a comment.<br>
<strong>2.</strong> everyone above gets an email</p>

<p>I hope I made myself clear. If not, I apologize. Thanks in advance. Remember, im still a beginner :) </p>
