php fetch from mysql limit same ID's
Posted: Wed Mar 17, 2010 3:22 pm
Hi all, have a little problem. I have details of every user in a table 'profileu' and when they comment on a picture the script will create a table and put their comment and Id in it. I am looking now to send an email to everyone that has also commented on it so I have made a little code below to search for all the users that have commented and get their email from profileu using their Id from the comments table..
That’s all fine, but if 1person has put say 5 comments on there, they will get sent 5 emails. I need to limit it so it can fetch many results from the comment table, but only take 1 of each Id. Everyone's Id is different.
Any ideas will be appreciated.
Thanks
Code: Select all
<?php
$othuyt = mysql_query("SELECT * FROM $comstbl");
While($othujk = mysql_fetch_object($othuyt)){
$otherc = mysql_query("SELECT * FROM profileu where id = '$othujk->frmid'");
$othcom = mysql_fetch_object($otherc);
$othem = $othcom->email;
<code to send details in email to $othem>
}
?>Any ideas will be appreciated.
Thanks