<?php
if (
$result = mysqli_query(
$mysqli,
"SELECT MIN(g.title) title,SUM(points)
FROM points p INNER JOIN `groups` g ON p.group_id = g.id
WHERE `attempt_id`IN (SELECT id FROM attempts WHERE status = 1) GROUP BY `group_id`"
)
) {
// Fetch all
$gpcrow = mysqli_fetch_all($result, MYSQLI_ASSOC);
print_r($gpcrow);
// Free result set
// Free result set
mysqli_free_result($result);
}