Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <h3>Kolom dan baris tabel otomatis</h3>
- <table border="1" width="20px">
- <tr><th>Nama Pegawai</th>
- <?php
- $jml_hari=date('t');
- for($i=1;$i<=$jml_hari;$i++){
- echo "<th>$i</th>";
- }
- echo "</tr>\n";
- //-- konfigurasi database
- $dbhost='localhost';
- $dbuser='root';
- $dbpass='';
- $dbname='test';
- //---
- //$db=new mysqli($dbhost,$dbuser,$dbpass,$dbname);
- $db=mysql_connect($dbhost,$dbuser,$dbpass);
- mysql_select_db($dbname);
- $sql="SELECT nip,SUM(edc) AS jml,DAY(tanggal) AS tgl FROM divisi GROUP BY nip,tanggal ORDER BY nip,tanggal";
- //$result=$db->query($sql);
- $result=mysql_query($sql,$db);
- $nip='';
- //while($data=$result->fetch_object()){
- while($data=mysql_fecth_object($result)){
- echo ($nip!=$data->nip?"<tr><td>{$data->nip}</td>":"");
- for($i=1;$i<=$jml_hari;$i++){
- echo ($i==$data->tgl?"<td>{$data->jml}</td>":"<td> </td>");
- }
- echo "</tr>\n";
- }
- ?>
- </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement