I am using the following script to count records, the way I think it should be working should be.
'some heading' x4
but instead it is outputting 'some heading' 1x 1x 1x 1x
include("connectmysqli.php");
if (isset($_GET['questionnaireID'])) {$questionnaireID = $_GET['questionnaireID'];}else {$questionnaireID = '';}
echo '<p><strong>View Questionnaire Results</strong></p>';
$sql1 = <<<SQL
SELECT answer1, COUNT(answer1)
FROM `QuestionnaireAnswers`
WHERE questionnaireID='$questionnaireID'
GROUP BY answer1
SQL;
if(!$result1 = $db->query($sql1)){ die('There was an error running the query [' . $db->error . ']');}
while($row1 = $result1->fetch_assoc()){
echo $row1['COUNT(answer1)'] . ' X <strong>' . $answer1 . '</strong><br />';
}
Here is an example of the table
So using the above screen shot, the column answer1 when counted should be 2x , but what is actually displayed is 1x 1x
If I run the query from the answers in phpmyadmin I get :