Chiunque può aiutarmi a risolvere questo problema? Voglio solo ottenere il totale o la somma di determinate colonne, per favore fai riferimento all'immagine qui sotto. Sto provando a ordinare questo per 2 giorni ma non posso ottenere non avere fortuna, Spero che qualcuno mi possa aiutare con questo. Lo apprezzo molto, e grazie in anticipo .sum of array column
Ecco un esempio di immagine http://www.freeimagehosting.net/pig81
<?php $sql = "SELECT name, doc_date, descs, debit, credit FROM statement WHERE
member_id = $member_id ORDER BY doc_date";
$query = mysql_query($sql);
$combinedResults = array();
while($result = mysql_fetch_array($query)) {
$combinedResults[$result[`name`]][] = array(`name` => $result[`name`], `doc_date` =>
$result[`doc_date`], `descs` => $result[`descs`],`debit` => $result[`debit`], `credit`
=> $result[`credit`]);}
foreach(array_keys($combinedResults) as $groupKey) { ?>
<table>
<tr><?php foreach($combinedResults[$groupKey] as $item) {?>
<td>Date</td>
<td>Description</td>
<td>Debit</td>
<td>Credit</td>
<td>Balance</td>
</tr>
<tr>
<td colspan="2"><?php echo $groupKey; ?></td>
<td width="105"> </td>
<td width="105"> </td>
<td width="105"> </td>
</tr>
<tr><?php foreach($combinedResults[$groupKey] as $item) {?>
<td><?php echo $item[`doc_date`];?></td>
<td><?php echo $item[`descs`];?></td>
<td><?php echo $item[`debit`];?></td>
<td><?php echo $item[`credit`]; ?></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td>sum of debit goes here</td>
</tr>
<?php }} ?>
</table>
hi ghoti, grazie per la risposta. Penso che funzioni, ma ha solo bisogno di un piccolo aggiustamento perché loop o visualizza più risultati a seconda del numero di elementi. ecco l'output di esempio http://www.freeimagehosting.net/xx7bc –
hi ghoti, è di nuovo me. LAVORA SUBITO, grazie mille per il tuo tempo e il tuo aiuto .. apprezzo tanto. –
Nessun problema. Grazie per l'upvote. – ghoti