03-Apr-2023
.
Admin
Hi Dev,
This tutorial is focused on how to get a sum of columns in PHP MySQL. you'll learn how to find the sum of columns in PHP MySQL. We will use how to get a sum of a column in PHP MySQL. if you have a question about how to find the sum of a column in PHP MySQL then I will give a simple example with a solution.
Now, let's see the article on how to find the sum of a column in the PHP MySQL. it's a simple example of how to get a sum of a column in PHP MySQL. you can understand the concept of how to find the sum of columns in PHP MySQL. if you have a question about how to get a sum of columns in PHP MySQL then I will give a simple example with a solution.
Example:
index.php
<?php
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "myDB";
// Create a connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check the connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT SUM(fees) FROM students";
$result = mysqli_query($conn, $sql);
while($row = mysqli_fetch_assoc($result)) {
echo "Total:" . $row['SUM(fees)'];
}
mysqli_close($conn);
?>
Output:
Total: 1000
I hope it could help you...
#PHP