誰做:它爲什麼給我這個通知?
echo $post['avg']
給我:
Notice: Undefined index: avg in posts.php on line 39
SELECT p.id, p.message, p.poster, avg(r.rating)
FROM posts p
LEFT OUTER JOIN userpostratings r ON p.id = r.postID
WHERE p.id = 1
GROUP BY p.id
CREATE TABLE IF NOT EXISTS `userpostratings` (
`userID` int(10) NOT NULL DEFAULT '0',
`postID` int(10) unsigned NOT NULL DEFAULT '0',
`rating` int(2) NOT NULL DEFAULT '0',
KEY `userPostRatings_userID` (`userID`),
KEY `userPostRatings_postID` (`postID`)
)
CREATE TABLE IF NOT EXISTS `posts` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`message` text,
`poster` int(10) unsigned NOT NULL DEFAULT '0',
`posted` int(10) unsigned NOT NULL DEFAULT '0',
`topic_id` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
)
您的意思是'$ _POST'? – 2011-06-08 19:09:06