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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:30:11+00:00 2026-06-01T04:30:11+00:00

EDIT: The plugin in question is located here . PHP beginner here using a

  • 0

EDIT: The plugin in question is located here.

PHP beginner here using a JQuery Star Rating snippet and have gotten it to work perfectly. My problem is that it is currently configured to count and display the average of many ratings (for public applications). I’m trying to simplify the plugin so that it allows one to set a personal rating (as if rating your own songs in iTunes). The user may update their rating, but no partial stars would ever exist. I’ve broken the plugin many times trying to get it working, but to no avail. The mysql database exists as follows:

CREATE TABLE IF NOT EXISTS `pd_total_vote` (
  `id` int(11) NOT NULL auto_increment,
  `desc` varchar(50) NOT NULL,
  `counter` int(8) NOT NULL default '0',
  `value` int(8) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

If I can get it working the way I imagine, I wouldn’t require both the counter and value columns, simply a single INT column that holds a value between 1 and 5. Currently counter accumulates the number of votes, while value aggregates the ratings. The stars are then displayed using (value/counter)*20 (as a percentage). The PHP is below (original):

<?php

// connect to database

$dbh=mysql_connect ("localhost", "user", "pass") or die ('Cannot connect to the database');
mysql_select_db ("thenally_pd",$dbh);

if($_GET['do']=='rate'){
    rate($_GET['id']);
}else if($_GET['do']=='getrate'){

    // get rating

    getRating($_GET['id']);
}

// get data from table

function fetchStar(){
    $sql = "select * from `pd_total_vote`";
    $result=@mysql_query($sql);
    while($rs = @mysql_fetch_array($result,MYSQL_ASSOC)){
        $arr_data[] = $rs;
    }
    return $arr_data;
}

// function to retrieve

function getRating($id){
    $sql= "select * from `pd_total_vote` where id='".$id."' ";
    $result=@mysql_query($sql);
    $rs=@mysql_fetch_array($result);
    // set width of star
    $rating = (@round($rs[value] / $rs[counter],1)) * 20; 
    echo $rating;
}

// function to set rating

function rate($id){
    $text = strip_tags($_GET['rating']);
    $update = "update `pd_total_vote` set counter = counter + 1, value = value + ".$_GET['rating']."  where id='".$id."' ";
    $result = @mysql_query($update);
}

?>

Thanks for a point in the right direction,

Mike

  • 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-01T04:30:13+00:00Added an answer on June 1, 2026 at 4:30 am

    I am unsure as I have no access to the rating system you are using yet just glancing at what you have I guess you could keep the counter set to 1 (if removing it breaks the jQuery Rating System) and have the value updated by the person so when you fetch it they only see their value (make sure value can’t go above 5). That way if the value is set to 5 then it will show 5 because it isn’t finding other ratings…. (based on my understanding) You will also have to add a user id so you know which persons rating to fetch (since you want it personal). This depends on how dependent the application is a specific database design.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently using the confirmaction jQuery plugin found here: http://www.webstuffshare.com/2010/03/jquery-plugin-jconfirmaction/ And my question is
I'm using the jQuery Cycle plugin. The page in question is here: http://harrisonfjord.com/folio/test.html The
Beginner jquery question. I am using the Tokenizing Autocomplete Text Entry plugin, with the
I essentially have the same goal as in this question: Calling a jQuery plugin
Total beginner question about jQuery: I have a Form that contains several TextBoxes (input
I use edit-in-place plugin: http://arashkarimzadeh.com/jquery/7-editable-jquery-plugin.html I't works Great! I just need something to check
EDIT: OK, I believe the following solutions are valid: Use the jQuery AOP plugin.
I have a textarea that I'm able to edit with the jeditable plugin but
I am using Jquery form plugin to upload file in Ajax request.File is successfully
I am using Jquery form plugin to upload file in Ajax request.File is successfully

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.