Pemrograman Web
Menampilkan data tabel siswa ke website
Microsoft Windows [Version 10.0.19045.6216]
(c) Microsoft Corporation. All rights reserved.
C:\Users\A-14>cd c:\xampp\mysql\bin
c:\xampp\mysql\bin>mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.4.27-MariaDB mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> USE db_smk;
Database changed
MariaDB [db_smk]> SELECT * FROM tb_siswa;
+-----+------+---------------+--------------+---------------+-----------------+
| nis | nama | jenis_kelamin | tempat_lahir | tanggal_lahir | nama_ibukandung |
+-----+------+---------------+--------------+---------------+-----------------+
| 123 | Aan | Laki-laki | Pandeglang | 2005-11-30 | Siti |
| 124 | Iin | Perempuan | | NULL | Ani |
| 125 | Vino | Laki-laki | | 2009-01-16 | Yani |
+-----+------+---------------+--------------+---------------+-----------------+
3 rows in set (0.148 sec)
MariaDB [db_smk]>
Koding / Script:
<h1>Data Siswa</h1>
<table border="1" width="800">
<tr>
<th>NIS</th>
<th>Nama Siswa</th>
<th>Jenis Kelamin</th>
<th>Tempat Lahir</th>
<th>Tanggal Lahir</th>
<th>Nama Ibu Kandung</th>
</tr>
<?php
include "conn/config.php";
$perintah = "SELECT * FROM tb_siswa";
$query = mysqli_query($koneksi, $perintah);
while ($data = mysqli_fetch_row($query)) {
echo "
<tr>
<td>$data[0]</td>
<td>$data[1]</td>
<td>$data[2]</td>
<td>$data[3]</td>
<td>$data[4]</td>
<td>$data[5]</td>
</tr>";
}
?>
</table>
output:
Tidak ada komentar:
Posting Komentar