Advertisement
GWibisono

di kondisikan saja..

Feb 22nd, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.07 KB | None | 0 0
  1. <?php
  2. $surat=array('kontrak 1','kontrak 2','kontrak 3');
  3. $detail=array(
  4.     array(
  5.         array('aws','invoice','sp0'),
  6.         array('aws','invoice','sp0'),
  7.         array('aws','invoice','sp0'),
  8.        
  9.     ),
  10. 2=> array(
  11.         array('aws','invoice','sp0'),
  12.                
  13.     ),
  14. );
  15.  
  16.  
  17.  
  18.  
  19. ?><table border=1>
  20.         <thead>
  21.           <tr>
  22.             <th>No</th>
  23.             <th>KONTRAK  </th>
  24.             <th>AWS</th>
  25.             <th>Tipe</th>
  26.             <th>SP</th>
  27.           </tr>
  28.         </thead>
  29.         <tbody>
  30. <?php
  31.   $i = 1;  
  32. //while ($data = mysqli_fetch_array($query)) {
  33. foreach($surat as $id0=>$name){
  34.     $total=count($detail[$id0]);
  35.     $total2=$total==0?1:$total;
  36.     echo "
  37.           <tr>
  38.             <td rowspan=\"".$total2."\">" . $i . "</td>
  39.             <td rowspan=\"".$total2."\">" . $name."</td>";
  40.     if($total==0){
  41.         echo "<td colspan=3>&nbsp;</td></tr>";
  42.     }
  43.     else{
  44.         $i2=0;
  45.         foreach($detail[$id0] as $id1=>$row1){
  46.             echo "<td>".implode("</td><td>",$row1)."</td></tr>";
  47.             $i2++;
  48.             if($i2<$total) echo "<tr>";
  49.            
  50.         }
  51.    
  52.     }
  53.     $i++;
  54.  
  55.    
  56. }
  57. ?>  </tbody>
  58.  
  59. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement