Kamis, 08 Agustus 2013

PHP Indonesia - Facebook: gan ane lagi belajar menghitung total keseluruhan,...

PHP Indonesia - Facebook
PHP Indonesia is a community for everyone that loves PHP. Our focus is in the PHP world but our topics encompass the entire LAMP stack. Topics include PHP coding, to memcached handling, db optimizations, server stack, web server tuning, code deploying, hosting options and much much more. Youtube Channel : http://www.youtube.com/user/OurPHPIndonesia Twitter : @php_indonesia NOTE: Rules for Wall posting: https://www.facebook.com/groups/35688476100/doc/10151597056316101/ Daftar Keanggotaan : http://www.facebook.com/groups/35688476100/doc/10150671770741101/ 
gan ane lagi belajar menghitung total keseluruhan,...
Aug 9th 2013, 03:32, by Kurnia Elf

Kurnia Elf 3:32am Aug 9
gan ane lagi belajar menghitung total keseluruhan,
scriptnya seperti ini

<?php
// Variabel koneksi
$myHost = "localhost";
$myUser = "root";
$myPass = "";
$myDbs = "hitung";

// Konek ke MySQL Server
$koneksidb = mysql_connect($myHost, $myUser, $myPass, $myDbs);
if (! $koneksidb) {
echo "Failed Connection !";
}

// Memilih database pd MySQL Server
mysql_select_db($myDbs) or die ("Database not Found !");
// Rumus Hitung
$q="SELECT SUM(harga)AS jumlahgaji FROM angka";
$total = mysql_query ($q);
echo "jumlah gaji =", $total['jumlahgaji'];

?>

nah yang jadi masalah kenapa hasil nya ga tampil? yang tampil cuman "jumlah gaji="

Nuroel Hafnati 3:43am Aug 9
itu kurang perintahnya gan,,
coba edit begini

$q=mysql_query("SELECT SUM(harga)AS jumlahgaji FROM angka");
$total = mysql_fetch_array ($q);
echo "jumlah gaji =", $total['jumlahgaji'];

Fajar Wimaholic 3:44am Aug 9
$q="SELECT COUNT(harga) AS
jumlahgaji FROM angka";
$total=mysql_fetch_array(mysql_query($q));
echo "jumlah gaji = $total[jumlahgaji]";

Alsolendski Susetyo Prakoso 3:45am Aug 9
$gaji = mysql_fetch_array($total); echo $gaji[0]

Nuroel Hafnati 3:47am Aug 9
Ralat gan

$q=mysql_query("SELECT SUM(harga)AS jumlahgaji FROM angka");
$total = mysql_fetch_array ($q);
echo "jumlah gaji =".$total['jumlahgaji'];

Wah You Poetra 3:48am Aug 9
itu pasti pada field harganya menggunakan tipe data varchar yah. coba ganti field harganya dengan tipe data int maka akan bisa dijumlahkan...

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions

Tidak ada komentar:

Posting Komentar