Advertisement
cdsatrian

rowspan

Sep 25th, 2013
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.10 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.     $semester = $_GET['semester'];
  22.     $sql="SELECT  
  23.            a.hari,
  24.            b.namadosen,
  25.            c.jammengajar,
  26.            d.namamk,
  27.            d.sks,
  28.            e.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.     $result = mysql_query($sql);
  38.     $records=array();
  39.     while($r=mysql_fetch_array($result))
  40.     {
  41.       if(isset($records[$r['hari']]))
  42.       {
  43.         $records[$r['hari']]=array();
  44.         $records[$r['hari']]['num']=1;
  45.         $records[$r['hari']]['data']=array();
  46.         $records[$r['hari']]['data'][]=$r;
  47.       }
  48.       else
  49.       {
  50.         $records[$r['hari']]['data'][]=$r;
  51.         $records[$r['hari']]['num']++;        
  52.       }
  53.     }
  54.     $no=0;
  55.     foreach($records as $record)
  56.     {
  57.       $jml=0;
  58.       foreach($record['data'] as $row)
  59.       {
  60.       echo "
  61.      <tr class='style8'>
  62.        <td>".++$no."</td>"
  63.        .(++$jml==1?($record['num']==1?"<td>".$row['hari']."</td>":"<td rowspan='".$record['num'].">".$row['hari']."</td>"):"")
  64.        ."<td>".$row['jammengajar']."</td>
  65.        <td>".$row['namamk']."</td>
  66.        <td class='center'>".$row['sks']."</td>
  67.        <td class='center'>".$row['namadosen']."</td>
  68.        <td class='center'>".$row['namaruangan']."</td>
  69.      </tr>
  70.      ";
  71.       }
  72.     }
  73.     ?>
  74.   </tbody>
  75. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement