I m building a php notification system (kinda like facebook s).
It works as should, listing all events the way i want it. but i m trying to get it to understand that if it gets 3+ events on the same post, it will join these events into one notification.
我们现在看着这一点:
User 1 wrote on article-x
User 2 wrote on article-x
user 3 wrote on article-x
user 1 wrote on article-y
instead i want it to be printed like this :
user 1 and 2 others wrote on article-x
Been trying to read up on what i need to do this, but no luck. any pointers greatly appreciated. It s being queried like this:
$sesname = $_SESSION[ user_name ];
$sesid = $_SESSION[ full_name ];
$dbh = new PDO("mysql:host=$hostname;dbname=$db", $username, $password);
$stmt = $dbh->prepare("select * from comments WHERE full_name = $sesid and checked = 1 ");
$stmt->bindParam( :full_name , $safe_name, PDO::PARAM_INT, 5);
$stmt->execute();
$result = $stmt -> fetchAll();
foreach( $result as $row ) {
$name = $row[ name ];
$pid = $row[ pid ];
$commentid = $row[ id ];
$fullink = $row[ fullink ];
$datetime = $row[ dt ];
if ($name == $sesname){
} else {
echo "<div id= commentnote ><a href= http://{$fullink} >{$name}</a>kommenterte ditt <a href= {$fullink} >blogginnlegg</a><br><div class= updentry style= color: red ! important; cursor: pointer; margin-top: -35px; position: absolute; right: 8px; >x</div></div>";
}
}
Tried using your answers underneath, but without luck. Thanks for answering though, i really appreciate it :)