In PHP, what are some techniques for displaying both individual points and total group points from a MySQL table in the same output?

To display both individual points and total group points from a MySQL table in the same output, you can use a combination of SQL queries and PHP functions. First, retrieve the individual points using a SELECT query and display them in a loop. Then, calculate the total group points using an aggregate function in SQL and display it separately.

<?php
// Connect to MySQL database
$connection = mysqli_connect("localhost", "username", "password", "database");

// Retrieve individual points
$individualPointsQuery = "SELECT points FROM table";
$individualPointsResult = mysqli_query($connection, $individualPointsQuery);

echo "Individual Points:<br>";
while ($row = mysqli_fetch_assoc($individualPointsResult)) {
    echo $row['points'] . "<br>";
}

// Calculate total group points
$totalPointsQuery = "SELECT SUM(points) AS total_points FROM table";
$totalPointsResult = mysqli_query($connection, $totalPointsQuery);
$totalPoints = mysqli_fetch_assoc($totalPointsResult)['total_points'];

echo "<br>Total Group Points: " . $totalPoints;

// Close database connection
mysqli_close($connection);
?>