Skip to content

Instantly share code, notes, and snippets.

@IhwanID
Created August 2, 2018 23:10
Show Gist options
  • Save IhwanID/a0b83ef8187bfa3a100129365f142a81 to your computer and use it in GitHub Desktop.
Save IhwanID/a0b83ef8187bfa3a100129365f142a81 to your computer and use it in GitHub Desktop.
sample code of show database from mysql phpmyadmin
<?php
//kodingan koneksi
$mysqli = mysqli_connect("localhost", "root", "", "sekolah");
//get database
$result = mysqli_query($mysqli, "SELECT * FROM siswa ORDER BY id DESC");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Tampilkan Data dari Database</title>
</head>
<body>
<table width='80%' border=1>
<tr>
<th>Nama</th> <th>Alamat</th> <th>Kontak</th>
</tr>
<?php
while($data_siswa = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>".$data_siswa['nama']."</td>";
echo "<td>".$data_siswa['alamat']."</td>";
echo "<td>".$data_siswa['kontak']."</td>";
}
?>
</table>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment