I have answers from a database and i can count 1 now but i want to show the amount of times a answer is chosen. I have no qlue how to do that. For instance I want to count the amount of times 'answer_id' (the id of the answer) 1 and 2 are answered in 'question_id'(the question)
I tried setting a different if while above it but that didn't work out for me.
<?php
$conn = mysqli_connect('localhost', 'root','','survey_cms_4people');
if (!$conn){
echo "DATABSE ERROR!";
}
$variable = 1;
$countAnswerQuery = "SELECT COUNT(`answer_id`) FROM survey_answers WHERE question_id=$variable AND answer_id=$variable ";
$countanswerresult = mysqli_query($conn, $countAnswerQuery);
while ($row = mysqli_fetch_array($countanswerresult)) {
echo $row[0];
}
?>
I want to be able to count them automaticly and not write a sql query for every question / answer.