Note that there are some explanatory texts on larger screens.

plurals
  1. PORating system assistance
    primarykey
    data
    text
    <p>I am using a rating script from <a href="http://net.tutsplus.com/tutorials/html-css-techniques/building-a-5-star-rating-system-with-jquery-ajax-and-php/" rel="nofollow">http://net.tutsplus.com/tutorials/html-css-techniques/building-a-5-star-rating-system-with-jquery-ajax-and-php/</a></p> <p>But I want it to upload the ratings to a database and stop a person from voting the same picture all the time.</p> <p>This is my script to upload and set a cookie:</p> <pre><code>&lt;?php // Get id and voted value $id = $_POST['widget_id']; preg_match('/star_([1-5]{1})/', $_POST['clicked_on'], $match); $vote = $match[1]; // Connect to database and find the row which have the id $get = mysql_query("SELECT * FROM ratings WHERE id = '$id'"); while ($getdata = mysql_fetch_array($get)) { $total_votes = $getdata['total_votes']; $total_value = $getdata['total_value']; // See if the votes and value is 0 and if it aint it update the database and if it is were creating a new row if ($total_votes != 0 &amp;&amp; $total_value != 0) { $total_votes++; mysql_query("UPDATE ratings SET total_votes = '$total_votes' WHERE id = '$id'"); } else { mysql_query("INSERT INTO ratings (id, total_votes, total_value) VALUES ('$id', '1', '$vote')"); } // Sets the cookie $value = $id; // Send a cookie that expires in 24 hours setcookie($id, $value, time() + 3600 * 24); ?&gt; </code></pre> <p>But if the user already has voted he can still vote so I need someway to check if he has the cookie and a way to get the data from the mysql table and send it to the user.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload