hola gente necesito de su ayuda... necesito sacar el total por cada columna y mostrarla abajo de la tabla de datos. Asi como esta imagen..
<?php
if(isset($_POST['search']))
{
$valueToSearch = $_POST['valueToSearch'];
$valueToSearch2 = $_POST['valueToSearch2'];
// search in all table columns
// using concat mysql function
$query = "SELECT * FROM facturacion where item_mes LIKE '$valueToSearch' AND item_anio LIKE '$valueToSearch2' ORDER BY 'item_dia' ASC";
$search_result = filterTable($query);
}
else {
$query = "SELECT * FROM `facturacion`";
$search_result = filterTable($query);
}
// function to connect and execute the query
function filterTable($query)
{
$connect = mysqli_connect("localhost", "root", "", "registrador");
$filter_Result = mysqli_query($connect, $query);
return $filter_Result;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>PHP HTML TABLE DATA SEARCH</title>
<style>
table,tr,th,td
{
border: 1px solid black;
}
</style>
</head>
<body>
<form action="sss.php" method="post">
<input type="text" name="valueToSearch" placeholder="Ingrese Mes"><br><br>
<input type="text" name="valueToSearch2" placeholder="Ingrese Año"><br><br>
<input type="submit" name="search" value="Filter"><br><br>
<table>
<tr>
<th>Sujetas</th>
<th>Agravadas</th>
<th>Total</th>
</tr>
<!-- populate table from mysql database -->
<?php
while($row = mysqli_fetch_array($search_result)):?>
<tr>
<td><?php echo $row['item_sujetas'];?></td>
<td><?php echo $row['item_gravadas'];?></td>
<td><?php echo $row['item_total'];?></td>
</tr>
<?php endwhile;?>
</table>
</form>
</body>
</html>