SHOW:
|
|
- or go back to the newest paste.
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="mahasiswa"; |
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); |
28 | + | printf("Host information: %s\n", $mysqli-> host_info); |
29 | ||
30 | - | $sql="DESCRIBE data_mahasiswa;"; |
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 | - | |
35 | + | |
36 | - | print_r( $ar); |
36 | + | echo '<pre>'.print_r( $ar,1); |
37 | }else{ | |
38 | - | |
38 | + | |
39 | } | |
40 | ||
41 | /* Menutup Koneksi */ | |
42 | - | $mysqli- > close(); |
42 | + | $mysqli-> close(); |