PHP expert |
|
Best gemakkelijk, je maakt een tabel ratings, bv zo:
CREATE TABLE `ratings` (
`rating_id` int(15) NOT NULL auto_increment,
`item_id` int(11) NOT NULL,
`score` int(1) NOT NULL,
`ip` varchar(30) NOT NULL,
PRIMARY KEY (`rating_id`)
) ENGINE=MyISAM;
CREATE TABLE `ratings` ( `rating_id` int(15) NOT NULL AUTO_INCREMENT, `item_id` int(11) NOT NULL, `score` int(1) NOT NULL, `ip` varchar(30) NOT NULL, PRIMARY KEY (`rating_id`) ) ENGINE=MyISAM;
Om de score dan te berekenen doe je bv:
$sSqlScore = "SELECT AVG(`score`) AS `r_avgscore` FROM `ratings` WHERE `item_id` = " . $iID . "";
$sSqlScore = "SELECT AVG(`score`) AS `r_avgscore` FROM `ratings` WHERE `item_id` = " . $iID . "";
|