01-10-2008, 03:22 PM
|
#2 (permalink)
|
|
The Addict
Join Date: Jan 2008
Location: USA
Posts: 217
Thanks: 16
|
From what I see, your tables are set wrongly for rating tutorials. What you'd want is a new table like this:
sql Code:
CREATE TABLE `ratings` ( tut_id INT UNSIGNED NOT NULL, rating TINYINT UNSIGNED NOT NULL );
Then you'd insert the rating:
sql Code:
INSERT INTO `ratings` VALUES ($get, $rate);
You can get a rating by a subquery, like so:
sql Code:
SELECT *, ( SELECT AVG(`rating`) FROM `ratings` WHERE `ratings`.`tut_id` = `tutorials`.`id` ) AS `rating` FROM `tutorialz`;
Understand that I haven't tested this so I might have made a mistake, but this should work for you. 
__________________
Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning. - Rich Cook
|
|
|
|