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

  • Home
  • SEARCH
  • 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 8976153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:03:44+00:00 2026-06-15T19:03:44+00:00

I have a like system where everytime you click on the favorite the button

  • 0

I have a like system where everytime you click on the favorite the button adds a value to the database with the userid and msgid liked. On page load, it will check what got liked and what didn’t using mysql. If liked it will show the unlike button. But I want to show how many people have liked the msgid. I don’t know how to define the form which is created for the message.

Here is my code:

function listfav($msgid){
  $q = mysql_query("SELECT * FROM `fav` WHERE `msgid`='$msgid'");
  $q1 = mysql_num_rows($q);
  $n = 0;
  while($row = mysql_fetch_array($q1)){
    $n += 1;
  }
  return $n.' People favorited this!';
}
  • 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-15T19:03:45+00:00Added an answer on June 15, 2026 at 7:03 pm
    function listfav($msgid)
    {
        $q = mysql_query("SELECT COUNT(*) AS likes FROM `fav` WHERE `msgid`='$msgid'");
        $row = mysql_fetch_assoc($q);
        $likes = number_format($row['likes'], 0); // add formatting to the number
        return "{$likes} People favorited this!";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a field called system in my database which looks like this system
Why does .Net not have the System.Float type like System.String , System.Double etc.?
Essentially, I have a binary voting system Like/Dislike. Thee class is called Like It
I have a base class Parent like this: using System; using System.Collections.Generic; using System.Text;
I would like to have a nice easy to use file upload system on
I have a PHP script that very much like a commenting system, but requires
If I have a namespace like: namespace MyApp.Providers { using System; using System.Collections.Generic; using
Suppose I have a method like so: public byte[] GetThoseBytes() { using (System.IO.MemoryStream ms
In the book Linux System Programming I have read some like this: fgetc returns
If I have a service definition/implementation like this: using System; using System.ServiceModel; namespace aspace.service

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.