Tengo el siguiente problema, no se como hacer el arreglo para que me guarde si es la misma empresa el valor de la factura x mes y me de los totales por empresa al final por año y totales facturados x mes.
Por ejemplo carlos en enero ha comprado 2 veces por un valor de 10.00 cada vez
debe mostrar carlos 20.00 ener
deberia tener un resultado así:
Cliente enero febrero marzo abril........totales
Carlos 20.00 15.oo 25.00
Juan 10.00 10.00
Jose 10.00 10.00
totales 10.00 25.00 10.00 45.00
Tengo lo siguiente hecho:
Código PHP:
Ver original
<?php $anobusc = $_POST['anobusc']; include("conexion.php"); $consulta=("SELECT * FROM facturas ORDER BY fechafac"); $tr_empresas=""; $tr_totales=""; $fechafac = $row['fechafac']; $ano = $fecha[0]; $mes = $fecha[1]; $dia = $fecha[2]; if ($anobusc == $ano){ $tr_empresas.=" <tr> <td align='center'>".$row['empresa']."</td> <td align='center'>".$row['total']."</td> </tr> <tr> <td><br></td> </tr>"; } $tr_totales.=" <tr> <td align='center'></td> </tr> ";} ?> <style> body{font-family:Arial, Helvetica, sans-serif; font-weight:bold;} table.tabla_empresa{border:none;border-collapse:collapse} table.tabla_empresa{background-color:#BFBFBF;width:120%;} table.tabla_empresa th{background-color:#4D4D4D;color:#FFFFFF;border:1px solid #E6E6FA} table.tabla_empresa td{background-color:#FFFFFF;color:#08285A;font-weight:bold;} </style> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!-- Design by Free CSS Templates http://www.freecsstemplates.org Released for free under a Creative Commons Attribution License Name : Eponymous Version : 1.0 Released : 20130222 --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="keywords" content="" /> <meta name="description" content="" /> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/> <title>Italcompas</title> <link href="css/paginacion.css" type="text/css" rel="stylesheet"> <link href="css/style.css" rel="stylesheet" type="text/css" /> <link href="css/menu.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="bg"> <div id="outer"> <div id="header"> <div id="logo"> <h1> <a href="index.html"></a> </h1> </div><br><br> <h2 style="font-weight:bold; color:#FF8E18; text-align:center; font-size: 36px;">Facturas por año</h2> <p style="font-weight:bold; color:#FF8E18; text-align:center; font-size: 12px;"> Para imprimir exportar la base de datos a excel</p> <!-- <form method="GET" action=""/> Ingrese la fecha a buscar formato(aaaa-mm-dd) <input type="date" size="32" value="" name="fechareg"/> <a style="position:relative; margin: 0px 780px 0px;" href="contabilidad.php" >Volver</a> </form> --> <br /> <div id= "centrar_tabla"> <table class='tabla_empresa'> <tr> <th>Clientes</th> <th>Enero</th> <th>Febrero</th> <th>Marzo</th> <th>Abril</th> <th>Mayo</th> <th>Junio</th> <th>Julio</th> <th>Agosto</th> <th>Septiembre</th> <th>Octubre</th> <th>Noviembre</th> <th>Diciembre</th> <th>Totales</th> </tr> <?php echo $tr_empresas;?> </table> <div id= "centrar_tabla"> <table class='tabla_empresa'> <tr> <th><---Totales---></th> <th>Enero</th> <th>Febrero</th> <th>Marzo</th> <th>Abril</th> <th>Mayo</th> <th>Junio</th> <th>Julio</th> <th>Agosto</th> <th>Septiembre</th> <th>Octubre</th> <th>Noviembre</th> <th>Diciembre</th> <th>Totales</th> </tr> <?php echo $tr_totales;?> </table> </body> </html>
Gracias de antemano y saludos