GWibisono

like this

Mar 20th, 2014
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. <?php
  2. $sql="select a.Anggota_ID id,a.Nama_Anggota nama, count(a.Anggota_ID)c from anggota a, assign a2, bahagian b where a.anggota_id=a2.Anggota_ID and a.bahagian_id=b.bahagian_id
  3. group by a.Anggota_ID";
  4. $res=query($sql); //only make query and return result
  5. $s="<table>";
  6. while($row=fetch($res))
  7. {
  8.     $title="<td rowspan='{$row['c']}'>$row[Nama_Anggota]</td>";
  9. //learn what is 'rowspan'
  10.     $sql="select bahagian from assign a, bahagian b where a.anggota_id=$row[Anggota_ID] and a.bahagian_id=b.bahagian_id";
  11.     $res2=query($sql);
  12.     while($row2=fetch($res2))
  13.     {
  14.         $s.="<tr>".$title;$title='';
  15. //for every start we need to put the title     
  16.         $s.="<td>{$res2['bahagian']}</td>";
  17.         $s.="</tr>";
  18.        
  19.     }//while($row2=fetch($res2))
  20.    
  21. }//while($row=fetch($res))
  22. $s.="</table>";
  23. echo $s;$s='';
Advertisement
Add Comment
Please, Sign In to add comment