I wasn't sure if I should post this in the newb's area but here goes anyways. 😉
I have a reviews script that I want to be able to allow site visitors to rate reviews with. The table for reviews (taken from an SQL export) is:
CREATE TABLE reviews (
id mediumint(11) unsigned NOT NULL auto_increment,
prod varchar(60) NOT NULL default '',
creator varchar(60) NOT NULL default '',
url varchar(60) default NULL,
review text,
score mediumint(3) NOT NULL default '0',
date datetime NOT NULL default '0000-00-00 00:00:00',
rating mediumint(11) NOT NULL default '0',
PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=latin1 AUTO_INCREMENT=16 ;
I've tried updating the database with the following SQL code and I know it's way wrong:
//here is the update query
$query="UPDATE reviews SET rating = (+$rating) WHERE id=$id";
$result = @ ($query);
See, I don't want to update with a new rating score. I want to add new ratings to the pre-existing score value to create a sum of the two within the database.
I am self-taught and still learning but I can't figure out how to code this in. Any help would be greatly appreciated!