Jump to content

inserting data into a table


Recommended Posts

I am having a problem with updating 2 table entry's at time. If i take out the num_votes it will add the rating. I'm not sure if I'm not doing the math correctly or if its not being entered correctly, then again I could be way off.


@mysql_select_db($database) or die( "Unable to select database");
$title = mysql_real_escape_string(urldecode($_POST["title"]));
$rating= mysql_real_escape_string($_POST['rating']);
$find_query="SELECT * FROM movie WHERE title='$title'";

$find_rating= mysql_result($find_result, $i, "rating");
$find_num_votes= mysql_result($find_result, $i, "num_votes")

$sum_rating = $find_rating + $rating;
$sum_num_votes = $find_num_votes + 1;

include"scripts/connect.php" ;
@mysql_select_db($database) or die( "Unable to select database");
$title= mysql_real_escape_string($_POST['title']);
$error = '';

$sql_rating = "UPDATE movie SET rating='$sum_rating' num_votes='$sum_num_votes' WHERE title='$title'"; 
mysql_query($sql_rating) or die (mysql_error());

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.