calcul du total en php mysql
Bonjour,
J'ai un petit problème car j'ai un tableau qui est celui là
Citation:
Dates 1 2 3 4 5
2009-04-24 10 6 7 3 1
2009-04-25 11 10 1 2 1
TOTAL ??????????????????????????????????????
et moi ce que je veu c'est sa:
Citation:
Dates 1 2 3 4 5
2009-04-24 10 6 7 3 1
2009-04-25 11 10 1 2 1
TOTAL 22 18 11 9 7
mais je sai pas comment mis prendre pour pour afficher le résultat par collonne
sachant que mon tableau ce parcour comme sa --->
j'ai une date et sa fait ex: 2009-04-24 j+1, j+2, j+3 etc..
après j'ai une autre date 2009-04-25 j+1, j+2, j+3 etc..
tous ces résultat sorte de ma tables my sql
et mon code est en php
je vous montre mon code si sa peu vous aidé pour m'aider
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
$query = "SELECT DISTINCT customers_id, customers_date_ins, customers_from FROM customers WHERE customers_id>='0' " . $custom . " GROUP BY customers_date_ins ORDER BY customers_date_ins asc ";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)) {
$custom_date = $row["customers_date_ins"];
echo "</tr><tr style=\"text-align: center;\"><td width=\"100\">" . $custom_date . "</td>\r\n";
for ($i=1; $i<=5; $i++) {
$com_dat = strtotime($custom_date. '+' .$i. 'days');
$endDate = date('Y-m-d', $com_dat);
$query_comm = "SELECT count(IFNULL(co.comm_status,'0')) AS Nb_comm FROM customers cu inner JOIN comm co ON cu.customers_id=co.customers_id WHERE cu.customers_date_ins = '".$custom_date."' and cu.customers_from like '%".$presta."%' and co.comm_status ='1' and co.comm_date ='".$endDate."' ";
$result_com = mysql_query($query_comm);
while($row1 = mysql_fetch_assoc($result_com)) {
$comm_nb = $row1["Nb_comm"];
echo "<td width=\"100\">" . $comm_nb . "</td>\r\n";
}
}
}
echo "</tr><tr style=\"text-align: center;\"><td width=\"100\">TOTAL</td>\r\n"; |
Merci de votre aide car là je vois vraiment pas comment faire au moin es-ce possible???