Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8418255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:16:20+00:00 2026-06-10T02:16:20+00:00

I am making a notification script and currently have this to display multiple notifications

  • 0

I am making a notification script and currently have this to display multiple notifications about the same image as one, e.g john likes image_name, sarah likes image_name -> 2 people like image_name.

this is what i have so far.

$query = mysql_query("SELECT type, extra_id, COUNT(*), id AS count FROM `notifications` WHERE `receiver_id` = '14' AND `read` = '0' GROUP BY type, extra_id");
while($row = mysql_fetch_array($query)){

    if($row['count'] == 1){

        switch ($row['type']) {
            case "Following":
                echo "John Doe is now following you <br />";
            break;
            case "Liked":
                $image_id = $row['extra_id'];
                $image_q = mysql_query("SELECT * FROM `images` WHERE `id` = '$image_id' LIMIT 1");
                $image = mysql_fetch_array($image_q);
                echo "John Doe likes ".$image['heading']."<br />";
            break;
        }

    }   else   {

        switch ($row['type']) {
            case "Following":
                echo $row['count']." New Users are following you <br />";
            break;
            case "Liked":
                $image_id = $row['extra_id'];
                $image_q = mysql_query("SELECT * FROM `images` WHERE `id` = '$image_id' LIMIT 1");
                $image = mysql_fetch_array($image_q);
                echo $row['count']." Users Like ".$image['heading']."<br />";
            break;
        }

    }

}

And my database looks like this for notifications table.
http://i.minus.com/iZtrR0MNZ95Qn.png

And the output from the code is,

2 New Users are following you 
5 Users Like IMAGE_ID_29
John Doe likes IMAGE_ID_50

where it should be

2 New Users are following you
John Doe likes IMAGE_ID_29
2 Users like IMAGE_ID_50
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:16:22+00:00Added an answer on June 10, 2026 at 2:16 am

    Your query currently is:

    SELECT type, extra_id, COUNT(*), id AS count FROM `notifications` WHERE `receiver_id` = '14' AND `read` = '0' GROUP BY type, extra_id
    

    that is, your are using the id field as your count.

    You may probably want to rewrite it as:

    SELECT type, extra_id, COUNT(*) AS count, id FROM `notifications` WHERE `receiver_id` = '14' AND `read` = '0' GROUP BY type, extra_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making website that have notification 'button'. When user click this button, notification div
How do you go about making a new notification with one application inside of
Making a word document of our network set-up. We have about 7 servers and
I'm making a weeapp for notification center using iOSOpenDev. I have a UITextField on
I'm making a notification in android, but I have a small delay before the
many people seem to have problem in making this work, so i am not
I am using local notifications in a app I'm making. I use this: Class
I'm interested in providing a general I'm making an ajax call notification ... similar
Making my first steps in RIA Services (VS2010Beta2) and i encountered this problem: created
I have written a Userscript for Facebook and it groups similar notifications together. Now,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.