Comment Notification

Started on the old forum in May 2018 · view the original in the archive · old links redirect here

10 replies · 149 views · started 8 years ago · 1 min read

3 participants
tupac Developer · 95 posts #1

Hey guys, I'm trying to notify other members who commented under a status about the others who commented under the same status. For example, to notify me that "john commented under kevin's status" since i would have commented too. It works, but the problem is that it does not notify everyone who commented under the status, only the first person who commented is notifed about the others. How can i achieve this?

$shti = mysql_fetch_array(mysql_query("SELECT shouter, shout, id FROM ibwf_shouts WHERE id='".mysql_real_escape_string($shtid)."'"));
$chorn = mysql_fetch_array(mysql_query("SELECT max(byuid) FROM ibwf_notify WHERE actid='".mysql_real_escape_string($_GET["shtid"])."' AND myaction='shout-comment' ORDER BY byuid LIMIT 100"));
if($chorn[0]!=getuid_sid($sid))

{
$msg = "<a href="main.php?action=viewuser&who=$uid">".htm lspecialchars(getnick_uid("$uid"))."</a> Commented on ".htmlspecialchars(getnick_uid("$shti[0]"))." shout <a href="lists.php?action=moresht&shtid=".$shti[2]."#comnu">"".substr($shti[1],0,40).""</a>[br/]Auto Notification Msg";
autopm($msg, $chorn[0], 1);
}
something else Fellow · 2,296 posts #2

Something like:

$shti = mysql_fetch_array(mysql_query("SELECT shouter, shout, id FROM ibwf_shouts WHERE id='".mysql_real_escape_string($shtid)."'"));
$rows = mysql_query("SELECT byuid FROM ibwf_notify WHERE actid='".mysql_real_escape_string($_GET["shtid"])."' AND myaction='shout-comment'");
while ($row = mysql_fetch_array($rows))
{
    if($row[0]!=getuid_sid($sid))
    {
        $msg = "<a href="main.php?action=viewuser&who=$uid">".htm lspecialchars(getnick_uid("$uid"))."</a> Commented on ".htmlspecialchars(getnick_uid("$shti[0]"))." shout <a href="lists.php?action=moresht&shtid=".$shti[2]."#comnu">"".substr($shti[1],0,40).""</a>[br/]Auto Notification Msg";
        autopm($msg, $row[0], 1);
    }
}

Note: It maybe wrong as I am guessing at what the table names do.

tupac Developer · 95 posts #3

That's ok bro, the essense of it is how to make sure other users that also commented on the shout also receives the same message you can even use your own example

tupac Developer · 95 posts #4

It still doesn't send the notification to others who would have commented, only the first person that commented gets notifications of who else commented...

something else Fellow · 2,296 posts #5

what is the comments table? is it ibwf_shouts or ibwf_notify or something else?

tupac Developer · 95 posts #6

ibwf_shouts have the person who makes the shouts ibwf_notify has the user id who makes the shout with the shout id so that the notifcation can be sent, but the comment itself is originally stored in ibwf_comments but ibwf_notify tells me who is the shouter all those who commented on my shout. I just would like to use it the same way to tell everyone else who comments, but it only tells the first person who comments

something else Fellow · 2,296 posts #7

I don't think ibwf_notify table is needed.

It would be on the lines of:

$shti = mysql_fetch_array(mysql_query("SELECT shouter, shout, id FROM ibwf_shouts WHERE id='".mysql_real_escape_string($shtid)."'"));
$rows = mysql_query("SELECT byuid FROM ibwf_comments WHERE shtid='".mysql_real_escape_string($shtid)."'");
while ($row = mysql_fetch_array($rows))
{
    if($row[0]!=getuid_sid($sid))
    {
        $msg = "<a href="main.php?action=viewuser&who=$uid">".htm lspecialchars(getnick_uid("$uid"))."</a> Commented on ".htmlspecialchars(getnick_uid("$shti[0]"))." shout <a href="lists.php?action=moresht&shtid=".$shti[2]."#comnu">"".substr($shti[1],0,40).""</a>[br/]Auto Notification Msg";
        autopm($msg, $row[0], 1);
    }
}

shtid and byuid on ibwf_comments probably needs changing to what ever names they are.

tupac Developer · 95 posts #8

Thanks alot bro this worked well

tupac Developer · 95 posts #9

The only issue is that it sends the message also to the person who created the shout E.G Tupac commented on tupac's shout. How can it stop that?

something else Fellow · 2,296 posts #10

if($row[0]!=getuid_sid($sid)) should be blocking that from happening so I am not sure why its not working. (Would need to see full code to see what is wrong)

There is another problem where notification will be sent twice if someone has commented twice which can be fixed with DISTINCT: $rows = mysql_query("SELECT DISTINCT byuid FROM ibwf_comments WHERE shtid='".mysql_real_escape_string($shtid)."'");

ACIDCORE Junior · 30 posts #11

Something else replies will do the job.

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close