Code-Samples/php/Php-count.php Using COUNT Function in Mysqli connect_error) { die("Connection not established: " . $connection->connect_error); } $query = "Use Hospital;"; $connection->query($query); // Using COUNT Function $query = "SELECT COUNT(patient_age) ". "FROM Patient ". "WHERE patient_age >= 40"; $output = $connection->query($query); $count = $output->fetch_row(); echo "Total number of retrieved rows is ". $count[0]; $connection->close(); ?>