I have a table like this :
Test_ID Question_ID User_ID
---------------------------------
15 1 1
15 2 1
16 1 2
And im trying to go through the table and print out something like this for each user. :
Test id : # Number of questions : #
Im using this which I can only get to print out the test id.
$result = mysqli_query($conn, "SELECT DISTINCT(Test_ID) AS Tcode, COUNT(Question_ID) AS Qcount,User_ID FROM user_answers WHERE User_ID = 1");
while ($data = mysqli_fetch_array($result)) {
echo ''.$data['Tcode'].'';
echo ''.$data['Qcount'].'';
}