Advertisement
GWibisono

sesuaikan saja

Jan 24th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /*mysql> CREATE DATABASE mahasiswa;
  3.  
  4. mysql> USE mahasiswa;
  5.  
  6. mysql> CREATE TABLE data_mahasiswa ( nim char(9), nama char(50),
  7. umur int, tempat_lahir char(50), jurusan char (30) );
  8.  
  9. mysql> DESCRIBE data_mahasiswa;
  10. */
  11.  
  12. $host="localhost";
  13. $user="root";
  14. $pass="";
  15. $db="work_mujur";
  16.  
  17. $mysqli = new mysqli($host, $user, $pass, $db);
  18.  
  19. /* Membuka Koneksi */
  20. if (mysqli_connect_errno()) {
  21. printf("Connect failed: %s\n", mysqli_connect_error());
  22. exit();
  23. }else{
  24. //evertyhing looks fine
  25.  
  26. }
  27.  
  28. printf("Host information: %s\n", $mysqli-> host_info);
  29.  
  30. $sql="show tables from {$db};";
  31. $sql="describe gmjr_associations";
  32. if ($result = $mysqli->query($sql)) {
  33.                   while ($row = $result->fetch_assoc()) {
  34.                                 $ar[]=$row;
  35.                         }
  36.                        echo '<pre>'.print_r( $ar,1);
  37.               }else{
  38.    
  39.            }
  40.  
  41. /* Menutup Koneksi */
  42. $mysqli-> close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement