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 3603548
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:53:09+00:00 2026-05-18T20:53:09+00:00

I am using PHP/MYSQL/JQUERY. I have a site which have news section. On news

  • 0

I am using PHP/MYSQL/JQUERY.

I have a site which have news section. On news details page, I want to add star rating system which will allow user to rate the news story. I am using this jquery rating system http://www.fyneworks.com/jquery/star-rating/

Now, I am not getting what will be the database structure and then what I need to code in PHP. I need what logic will be applied for this, like if 1000 people voted for the article, some given rating as 2 or 3 or1 or 5. Then Where I should be storing (db structure) this all and what I’ll calculate (in php code).

If someone has any article which shows this concept please provide.

Please help, to understand the logic and concept of this.

Thanks!

  • 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-05-18T20:53:10+00:00Added an answer on May 18, 2026 at 8:53 pm

    here’s a very simple mysql example:

    drop table if exists image;
    create table image
    (
    image_id int unsigned not null auto_increment primary key,
    caption varchar(255) not null,
    num_votes int unsigned not null default 0,
    total_score int unsigned not null default 0,
    rating decimal(8,2) not null default 0
    )
    engine = innodb;
    
    drop table if exists image_vote;
    create table image_vote
    (
    image_id int unsigned not null,
    user_id int unsigned not null,
    score tinyint unsigned not null default 0,
    primary key (image_id, user_id)
    )
    engine=innodb;
    
    delimiter #
    
    create trigger image_vote_after_ins_trig after insert on image_vote
    for each row
    begin
     update image set 
        num_votes = num_votes + 1,
        total_score = total_score + new.score,
        rating = total_score / num_votes  
     where 
        image_id = new.image_id;
    end#
    
    delimiter ;
    
    insert into image (caption) values ('image 1'),('image 2'), ('image 3');
    
    insert into image_vote (image_id, user_id, score) values
    (1,1,5),(1,2,4),(1,3,3),(1,4,2),(1,5,1),
    (2,1,2),(2,2,1),(2,3,4),
    (3,1,4),(3,5,2);
    
    select * from image;
    select * from image_vote;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a news feed that has been developed using PHP, MySQL, and jQuery.
Using PHP and MySQL, I want to select only 6 rows from table which
I am using php and mysql. I have a Database config file (db-config.php) which
I'm using the source code found on this site here: http://webtint.net/tutorials/5-star-rating-system-in-php-mysql-and-jquery/comment-page-1/#comment-2562 A fantastic resource,
i want to import .txt file values into mysql using php and jquery/Ajax without
Im using jQuery/PHP/MySql to load twitter search results on the page but limited to
I have made a chat script using php, mysql and jquery. It uses json
I am currently using PHP/MySQL and the jQuery timeago plugin. Basically, I need to
Using PHP / MySQL all encoded up as UTF, we have recently had to
I'm using PHP/MySql. If I have two tables (hypothetically) as follows: id name and

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.