Array Count Question

Hi,

I’m trying to return a set of results back so I can output them in a graph plotter.

The results for a question in this instance will be 0,1,2,3,4,5 or 6 I want to count these and plot them out on a graph.

So far I’m using the below but it doesn’t seem to output as required. Any ideas on another solution?


function getResultsforColleagueQuestion($q, $id) {
	$db = db::getInstance();
		if ($result = $db->query("SELECT `cq_q1_".$q."` FROM `collegue_questionaire` WHERE `cq_question_number` = 7 AND `cq_user_id` ='" . $id . "'")) {
			if ($rows = $db->getrows($result)) {
					return array_count_values($rows[1]);
			}
		}
		
	}

#1 what database connection class are you using?
#2 you need an alternate return value (if there was an error, return -1 or some such)
#3 why would you count only the 2nd result? ($rows[1]). I think you meant to use array_count_values($rows);