Advertisement
cdsatrian

rowspan (alternative)

Sep 25th, 2013
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.13 KB | None | 0 0
  1. <style>
  2.   tr.style15 th {border:solid 1px #000000;background-color:#66CCCC}
  3.   tr.style8 td {border:solid 1px #000000;}
  4.   .center {text-align:center}
  5. </style>
  6. <table width="766" border="1" cellspacing="1" cellpadding="1">
  7.   <thead>
  8.     <tr class="style15">
  9.       <th width="25">No</th>
  10.       <th width="50">Hari </th>
  11.       <th>Jam</th>
  12.       <th width="302">Matakuliah</th>
  13.       <th width="30">SKS</th>
  14.       <th width="130">Dosen Pengajar</th>
  15.       <th width="150">Ruang</th>
  16.     </tr>
  17.   </thead>
  18.   <tbody>
  19. <?php
  20.     include "koneksi.php";
  21.     $sql="SELECT  
  22.           COUNT(1) AS jml,
  23.           a.hari,
  24.           GROUP_CONCAT(b.namadosen SEPARATOR '|') AS namadosen,
  25.           GROUP_CONCAT(c.jammengajar SEPARATOR '|') AS jammengajar,
  26.           GROUP_CONCAT(d.namamk SEPARATOR '|') AS namamk,
  27.           GROUP_CONCAT(d.sks SEPARATOR '|') AS sks,
  28.           GROUP_CONCAT(e.namaruang SEPARATOR '|') AS namaruang
  29.         FROM
  30.           tbljadwal a
  31.           JOIN tbldosen b USING(kodedosen)
  32.           JOIN tblwaktu c USING(koderuang)
  33.           JOIN tblmatakuliah d USING(kodemk)
  34.           JOIN tblruang e USING(koderuang)
  35.         WHERE
  36.           a.tingkatsemester = '".$_GET['angka']."'
  37.         GROUP BY
  38.           a.hari";
  39.     $result = mysql_query($sql);
  40.     $records=array();
  41.     $no=0;
  42.     while($r=mysql_fetch_array($result))
  43.     {
  44.       $count=0;
  45.       $jml=$r['jml'];
  46.       $namadosen=explode('|',$r['namadosen']);
  47.       $jammengajar=explode('|',$r['jammengajar']);
  48.       $namamk=explode('|',$r['namamk']);
  49.       $sks=explode('|',$r['sks']);
  50.       $namaruang=explode('|',$r['namaruang']);
  51.       for($i=0;$i<$jml;++$i)
  52.       {
  53.       echo "
  54.       <tr class='style8'>
  55.         <td>".++$no."</td>"
  56.          .(++$count==1?($jml==1?"<td>".$r['hari']."</td>":"<td rowspan='".$jml.">".$r['hari']."</td>"):"")
  57.          ."<td>".$jammengajar[$i]."</td>
  58.         <td>".$namamk[$i]."</td>
  59.         <td class='center'>".$sks[$i]."</td>
  60.         <td class='center'>".$namadosen[$i]."</td>
  61.         <td class='center'>".$namaruangan[$i]."</td>
  62.       </tr>
  63.       ";
  64.       }    
  65.     }
  66.     ?>
  67.   </tbody>
  68. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement