Tolong pilih kategori sesuai, jenis posting (diskusi atau bukan) dan sertakan tag/topik yang sesuai seperti komputer, java, php, mysql, dll. Promosi atau posting tidak pada tempatnya akan kami hapus!
- Bagi Anda yang ingin mendaftar, baca link berikut:
http://diskusiweb.com/discussion/50491/how-to-registrasi-diskusiweb-com-baca-ini-terlebih-dahulu
- Cara menyisipkan kode program supaya tampil rapi dan terformat dengan baik di diskusiweb.com: http://www.diskusiweb.com/discussion/50415/cara-menyisipkan-kode-program-di-diskusiweb-com
- Cara posting gambar/image di post Anda: http://www.diskusiweb.com/discussion/47345/cara-menyisipkan-menyertakan-image-pada-posting/p1

[Tanya] Bagaimana Rumus Menghitung Transaksi Pertanggal

bagaimana caranya memasukan rumus menghitung transaksi pertanggal, berikut ini kode :

<?php
$bulan = $_GET['bulan'];
echo date('F Y', strtotime($bulan));?>
<?php echo"</div>
";



//$sql = mysql_query("SELECT * FROM tb_detail_penjualan group by timestmp LIKE '%$_GET[bulan]%'") or die(mysql_error());
$sql = mysql_query("SELECT * FROM tb_penjualan where tgl_transaksi LIKE '%$_GET[bulan]%'") or die(mysql_error());
$no = 0;
while($p = mysql_fetch_assoc($sql))
{
$no++;
//$sqla = mysql_fetch_array(mysql_query("SELECT SUM(qty) as qty FROM tb_penjualan group by tgl_traksasi AND timestmp LIKE '%$_GET[bulan]%'"));
$sqla = mysql_fetch_array(mysql_query("SELECT SUM(qty) as qty FROM tb_detail_penjualan WHERE no_transaksi='$p[no_transaksi]' AND timestmp LIKE '%$_GET[bulan]%'"));
//$tglnya = mysql_fetch_array(mysql_query("SELECT COUNT(tgl_transaksi) as count FROM tb_penjualan WHERE timestmp LIKE '%$_GET[bulan]%'"));

}

$transaksi = mysql_fetch_array(mysql_query("SELECT COUNT(tgl_transaksi) as count FROM tb_penjualan WHERE timestmp LIKE '%$_GET[bulan]%'"));
$qty = mysql_fetch_array(mysql_query("SELECT SUM(qty) as qty FROM tb_detail_penjualan WHERE timestmp LIKE '%$_GET[bulan]%'"));
$total = mysql_fetch_array(mysql_query("SELECT SUM(total_harga) as total FROM tb_penjualan WHERE metode='cash' AND timestmp LIKE '%$_GET[bulan]%'"));
$transfer = mysql_fetch_array(mysql_query("SELECT SUM(total_harga) as total FROM tb_penjualan WHERE metode='transfer' AND timestmp LIKE '%$_GET[bulan]%'"));
$credit = mysql_fetch_array(mysql_query("SELECT SUM(total_harga) as total FROM tb_penjualan WHERE metode='credit card' AND timestmp LIKE '%$_GET[bulan]%'"));
$bca = mysql_fetch_array(mysql_query("SELECT SUM(total_harga) as total FROM tb_penjualan WHERE kartu='bca' AND timestmp LIKE '%$_GET[bulan]%'"));
$mandiri = mysql_fetch_array(mysql_query("SELECT SUM(total_harga) as total FROM tb_penjualan WHERE kartu='mandiri' AND timestmp LIKE '%$_GET[bulan]%'"));
$maybank = mysql_fetch_array(mysql_query("SELECT SUM(total_harga) as total FROM tb_penjualan WHERE kartu='maybank' AND timestmp LIKE '%$_GET[bulan]%'"));
$citibank = mysql_fetch_array(mysql_query("SELECT SUM(total_harga) as total FROM tb_penjualan WHERE kartu='citibank' AND timestmp LIKE '%$_GET[bulan]%'"));
$bni = mysql_fetch_array(mysql_query("SELECT SUM(total_harga) as total FROM tb_penjualan WHERE kartu='bni' AND timestmp LIKE '%$_GET[bulan]%'"));
$mega = mysql_fetch_array(mysql_query("SELECT SUM(total_harga) as total FROM tb_penjualan WHERE kartu='mega' AND timestmp LIKE '%$_GET[bulan]%'"));
$bri = mysql_fetch_array(mysql_query("SELECT SUM(total_harga) as total FROM tb_penjualan WHERE kartu='bri' AND timestmp LIKE '%$_GET[bulan]%'"));
$cimbniaga = mysql_fetch_array(mysql_query("SELECT SUM(total_harga) as total FROM tb_penjualan WHERE kartu='cimb niaga' AND timestmp LIKE '%$_GET[bulan]%'"));

echo"";
echo"";
?>
<?php
Total
Total Transaksi - Cash
Total Transaksi - Transfer
Total Transaksi - Credit Card
Credit Card - BCA
Credit Card - Mandiri
Credit Card - MayBank
Credit Card - BRI
Grand Total Transaksi
".$qty['qty']."
".number_format($total['total'])."
".number_format($transfer['total'])."
".number_format($credit['total'])."
".number_format($bca['total'])."
".number_format($mandiri['total'])."
".number_format($maybank['total'])."
".number_format($bri['total'])."
".number_format($total['total']+$credit['total']+$transfer['total'])."
Tagged:

Comments

  • wuih ribet banget yaa...
    itu banyak banget pakai perintah sqlnya apa gak lemot kalo banyak ada transaksi di table ?
    kenapa tidak di group by kartu ?
Sign In or Register to comment.