Hello,
I'm trying to get a code to work but it isn't quite working. Its going to be a feedback system and it will show the positive, neutral and negative feedback over 1 month, 6 months, and 12 months. There is a script I saw that does something similar, though I couldn't quite get it to work. Not sure what is wrong.
Basically the goal of the code below is to find the total number of positive feedback (case 1), neutral feedback (case 2) and negative feedback (case 3) that occurred within the past 1 month.
$stats = $vbulletin->db->query_read("
SELECT feedback_rating, COUNT(*) AS feedback_count
FROM " . TABLE_PREFIX . "forumgold_feedback
WHERE feedback_to = " . $vbulletin->userinfo['userid'] . "
AND feedback_timestamp >= " . mktime(0,0,0,date('m')-1,date('d'),date('Y')) . "
GROUP BY feedback_rating
");
while ($vbulletin->db->fetch_array($stats)) {
switch ($stats['feedback_rating']) {
case 1:
$post['pos1'] = $stats['feedback_count'];
break;
case 2:
$post['neu1'] = $stats['feedback_count'];
break;
case 3:
$post['neg1'] = $stats['feedback_count'];
break;
default:
// Just incase
}
}
Any idea's?
Worst come to worst I would just have to do a query for each type of feedback. Would have to do, WHERE feedback_rating = 1, etc. Would like to figure out how to utilize the group by though.
Thanks!