View difference between Paste ID: PWPZ277d and k5LBvhEW
SHOW: | | - or go back to the newest paste.
1-
mysql> CREATE DATABASE mahasiswa;
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-
mysql> DESCRIBE data_mahasiswa;
8+
9
mysql> DESCRIBE data_mahasiswa;
10
*/
11
12
$host="localhost";
13
$user="root";
14
$pass="";
15
$db="mahasiswa";
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="DESCRIBE data_mahasiswa;";
31
if ($result = $mysqli->query($sql)) {
32
                  while ($row = $result->fetch_assoc()) {
33
                                $ar[]=$row;
34
                        }
35
                       
36
                        print_r( $ar);
37
              }else{
38
    
39
           }
40
41
/* Menutup Koneksi */
42
$mysqli- > close();