gundambison

update 60

May 10th, 2018
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /***
  3. update koneksi dibawah!!
  4.  
  5. ***/
  6.     if(is_file('koneksi.php')){
  7.         include'koneksi.php';
  8.     }
  9. ?>
  10. <html>
  11. <head></head>
  12. <body>
  13.     <table border="1">
  14.         <thead align="center">
  15.             <tr>
  16.                 <th>Hasil</th>
  17.                 <?php
  18.                 for($j=0;$j<10;$j++){
  19.                     echo "<th>$j</th>";
  20.                 }
  21.                 ?>
  22.             </tr>
  23.         </thead>
  24.         <?php
  25.         for($i=0;$i<10;$i++){
  26.             echo '<tr>';
  27.             $n=$i/100;
  28.             echo '<td>'.$n.'</td>';
  29.             for($j=0;$j<10;$j++){
  30.                 $n=($i*10+$j)/100;
  31.                 echo "<td>".get_num($n)."</td>";
  32.             }
  33.             echo '</tr>';
  34.         }
  35. /**
  36.             stat($i);
  37.             $N1=floor($i*10)/10;
  38.             $N2=floor($i*100)%10;
  39.             mysqli_select_db($koneksi,"tabelz");
  40.             $query="SELECT z".$N1." as num from tabelZ where noZ='$N1'";
  41.             $sql=mysqli_query($query);
  42.             $total=mysqli_num_rows($sql);
  43.             while($data=mysqli_fetch_array($sql))
  44.             {
  45.         ?>
  46.         <tbody>
  47.             <tr>
  48.                 <td><?php echo $data['num'];?></td
  49.             </tr>
  50.         <?php }
  51.  
  52. */
  53. ?>
  54.         </tbody>
  55.     </table>
  56. </body>
  57.        
  58. </body>
  59. </html>
  60. <?php
  61. function get_num($i){
  62.     $mysqli = koneksi();
  63.     $N1=floor($i*10)/10;
  64.     $N2=floor($i*100)%10;
  65.             //mysqli_select_db($koneksi,"tabelz");
  66.     $query="SELECT z".$N2." as num from tabelZ where noZ='$N1'";
  67.      
  68.             //$sql=mysqli_query($query);
  69.     if($result= $mysqli->query($query)){
  70.             $row = $result->fetch_array();
  71.     }else{
  72.         $row=array('num'=>$query);
  73.     }
  74.     return $row['num'];
  75. }
  76.  
  77. function koneksi(){
  78. //update ini
  79. $mysqli = new mysqli("localhost", "root3", "", "fb_statistik");
  80. if(mysqli_connect_errno()){
  81.     echo 'Gagal melakukan koneksi ke Database : '.mysqli_connect_error();
  82.     exit;
  83. }
  84. return $mysqli;
  85.  
  86. }
Advertisement
Add Comment
Please, Sign In to add comment