I have a little problem here..
I have a code to create an array for a table like this:
$sql = "
SELECT t.jumBarang,t.hargaJual,b.namaBarang
FROM barang AS b, detail_jual AS t
WHERE t.nomorStruk = '$_POST[idTransaksi2]' AND t.barcode=b.barcode
";
$hasil = mysql_query($sql);
Let's say from the query above it returns 3 rows, so if I want to create that row count as my tr (3 tr) I'll use this code..
while ($x = mysql_fetch_array($hasil)) { #create <tr> }
so the result become...
<tr></tr>
<tr></tr>
<tr></tr>
But the problem is, how if I want to create a row as my mysql column sum result...
let's say..
ID | Quantity | key
-------------------
1 | 2 | 1
2 | 3 | 1
-------------------
now how to create an array <tr>
by using sum(quantity) result (2+3=5 , 5rows)
<tr></tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr></tr>
Issue another query to calculate the sum:
SELECT sum(*)
FROM barang AS b, detail_jual AS t
WHERE t.nomorStruk = '$_POST[idTransaksi2]' AND t.barcode=b.barcode