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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:39:55+00:00 2026-05-13T19:39:55+00:00

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,

  • 0

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 think you’ll all agree, but my problem is that my Javascript doesn’t appear to be actually executing the PHP script…

When I add a breakpoint in Chrome’s debugger for the penultimate line (before }); ):

$("[id^=rating_]").children("[class^=star_]").click(function() {

        var current_star = $(this).attr("class").split("_")[1];
        var rid = $(this).parent().attr("id").split("_")[1];

        $('#rating_'+rid).load('http://localhost:8888/fivestars/send.php', {rating: current_star, id: rid});


    });

It stops on the breakpoint successfully, as you’d expect. However I just can’t get send.php to actually DO anything, it simply won’t! As you can see from the code I’ve used an absolute URL but it won’t work with relative URL or just send.php in that place. I’ve placed code in send.php that writes ‘Success’ to the database just so I can test that it’s being executed – but clearly isn’t.

Does anyone have any ideas?

Thanks!

Jack

EDIT: Just tried this code in place of what I was previously using:

$('#rating_'+rid).load('send.php', function () {alert('Load was performed.');});

The dialogue displays correctly, so I’m confident it’s working.

For reference, the PHP code of send.php is:

<?php

$rating = (int)$_POST['rating'];
$id = (int)$_POST['id'];

$this->db->query("INSERT INTO code (rating) VALUE (8)");
$query = $this->db->query("SELECT * FROM code WHERE id = '".$id."'");

while($query->row()) {

    if($rating > 5 || $rating < 1) {
        echo"Rating can't be below 1 or more than 5";
    }

    elseif(isset($_COOKIE['rated'.$id])) {
        echo"<div class='highlight'>You've already voted, sorry!</div>";
    }
    else {
        setcookie("rated".$id, $id, time()+60*60*24*365);

//      $total_ratings = $row['total_ratings'];
        $total_ratings = $query->row('total_ratings');
        $total_rating = $query->row('total_rating');
        $current_rating = $query->row('rating');

        $new_total_rating = $total_rating + $rating;
        $new_total_ratings = $total_ratings + 1;
        $new_rating = $new_total_rating / $new_total_ratings;
        // Lets run the queries. 

        $this->db->query("UPDATE test SET total_rating = '".$new_total_rating."' WHERE id = '".$id."'");
        $this->db->query("UPDATE test SET rating = '".$new_rating."' WHERE id = '".$id."'");
        $this->db->query("UPDATE test SET total_ratings = '".$new_total_ratings."' WHERE id = '".$id."'");

        echo"<div class='highlight'>Thanks for your vote!</div>";

    }
}

?>

Sorry that’s a little messy, but I’ve been migrating default PHP code to my CodeIgniter Libraries.

  • 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-13T19:39:55+00:00Added an answer on May 13, 2026 at 7:39 pm

    First thing to check would the the access and error logs from the web server to see if the request is actually getting to the web server.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Does anyone know how can I replace this 2 symbol below from the string
I'm making a simple page using Google Maps API 3. My first. One marker
We're building an app, our first using Rails 3, and we're having to build
I have some data like this: 1 2 3 4 5 9 2 6

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.