Reseller Domain Murah dan termurah di Indonesia? ya di ResellerCamp.
         
 

Forum PHP Indonesia

 
Advanced Search
   
 
Home Register FAQ Memberlist Usergroups  
 
 

Forum PHP Indonesia Forum Index Oracle, MSSQL, Postgre, MS Access menampilkan jml laki-laki dan perempuan dalam satu query
Display posts from previous:   
      All times are GMT + 7 Hours  

menampilkan jml laki-laki dan perempuan dalam satu query

Post new topic  Reply to topic

Fri Jul 23, 2010 11:40
Author Message
bennozuke
PHPnewbie
PHPnewbie


Joined: 28 May 2008
Posts: 18

Post subject: menampilkan jml laki-laki dan perempuan dalam satu query Reply with quote

Code:
<?php $sql="SELECT a.id_pkt,a.jn_pkt, a.gol_pkt,count(b.nip) as jumlah_p FROM pangkat_sdetail a
        LEFT JOIN tbl_pribadi b on a.id_pkt=b.id_pkt
        WHERE b.jn_kelamin='P'
        GROUP BY a.id_pkt, a.jn_pkt,a.gol_pkt
        ORDER BY a.id_pkt"
;
    
//echo $sql;
        
$conn $osql->odb->query($sql);
        
$row=$conn->fetchAll(PDO::FETCH_ASSOC);
        
//print_r($row_journal);
        
$no=1;
        for(
$i=0;$i<count($row);$i++)
        {
            
$jn_pkt=$row[$i]['jn_pkt'];
            
$gol_pkt=$row[$i]['gol_pkt'];
            
$jumlah_p=$row[$i]['jumlah_p'];
           
$str.="<tr>
            <td class=\"td_b\" align=\"center\" valign=\"top\">{$no}</td>
                    <td class=\"td_b\" align=\"left\" valign=\"top\">{$jn_pkt}</td>
            <td class=\"td_b\" align=\"center\" valign=\"top\">{$gol_pkt}</td>
            <td class=\"td_b\" align=\"center\" valign=\"top\">{$jumlah}</td>
            <td class=\"td_b\" align=\"center\" valign=\"top\">{$jumlah_p}</td>
                </tr>"
;
            
$no++;
        } 
?>


code di atas cuma bisa nampilin jml perempuan aja, supaya bisa nampilin jml laki-laki dan perempuan gmn caranya ya? Cry
_________________
my name is iben
 
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
      Back To Top  

Fri Jul 23, 2010 13:07
Author Message
andriant
Jagoan PHP
Jagoan PHP


Joined: 31 Mar 2010
Posts: 911
Location: Jakarta

Post subject: Reply with quote

SELECT a.id_pkt,a.jn_pkt, a.gol_pkt,count(b.nip) as jumlah_p FROM pangkat_sdetail a
LEFT JOIN tbl_pribadi b on a.id_pkt=b.id_pkt

GROUP BY a.id_pkt, a.jn_pkt,a.gol_pkt
ORDER BY a.id_pkt
_________________
Lagi Boker, Makan, Mau Tidur, Coding jangan lupa baca:
PHP Manual -> http://php.net/download-docs.php
MySQL Manual -> http://dev.mysql.com/doc/
 
View user's profile Send private message Visit poster's website Yahoo Messenger
      Back To Top  
Post new topic  Reply to topic

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


      Back To Top  

Page 1 of 1
Jump to:  
Powered by phpBB © 2001, 2002 phpBB Group
Toko Kaos Couple | Avalanche style by What Is Real © 2004 | Toko Baju Butik Online | Cara Pedia | Busana Baju Muslim