Hallo berikut tugas pemograman web yang saya buat
1. pertama buat database dengan nama "perpustakaan"
2. Lalu buatlah tabel dengan nama "buku"
3. kemudia buat 6 buah field dengan nama: kode_buku, judul_buku, penulis, penerbit, tahun_terbit, harga.
4. Tambahkan record minimal 20 buah
5. buka code editor dan buat file PHP baru dengan nama "koneksi.php" lalu pastekan script berikut.
<?php
$koneksi =mysqli_connect("localhost","root","","perpustakaan");
// Cek koneksi
if (mysqli_connect_errno()){
echo "koneksi database gagal : " . mysqli_connect_error();
}
?>
6. Buat file PHP baru dengan nama "perpustakaan.php" lalu simpan dengan folder yang sama dengan file "koneksi.php" dan pastekan script berikut
8. Maka akan muncul tampilan seperti ini
Atas perhatiannya saya ucapkan terimakasih banyak
1. pertama buat database dengan nama "perpustakaan"
2. Lalu buatlah tabel dengan nama "buku"
3. kemudia buat 6 buah field dengan nama: kode_buku, judul_buku, penulis, penerbit, tahun_terbit, harga.
4. Tambahkan record minimal 20 buah
5. buka code editor dan buat file PHP baru dengan nama "koneksi.php" lalu pastekan script berikut.
<?php
$koneksi =mysqli_connect("localhost","root","","perpustakaan");
// Cek koneksi
if (mysqli_connect_errno()){
echo "koneksi database gagal : " . mysqli_connect_error();
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Perpustakaan</title>
</head>
<style>
.container{
margin: auto;
width: 900px;
}
</style>
<body>
<div class="container">
<h2>Index Buku</h2>
<table border="1" cellspacing="0" cellpadding="5">
<tr>
<th>No</th>
<th>Kode Buku</th>
<th>Judul Buku</th>
<th>Penulis</th>
<th>Penerbit</th>
<th>Tahun Terbit</th>
<th>Harga</th>
</tr>
<?php
include 'koneksi.php';
$no = 1;
$data = mysqli_query($koneksi,"SELECT * FROM buku");
while($b = mysqli_fetch_array($data)){
?>
<tr>
<td><?php echo $no++; ?></td>
<td><?php echo $b['kode_buku']; ?></td>
<td><?php echo $b['judul_buku']; ?></td>
<td><?php echo $b['penulis']; ?></td>
<td><?php echo $b['penerbit']; ?></td>
<td><?php echo $b['tahun_terbit']; ?></td>
<td><?php echo $b['harga']; ?></td>
</tr>
<?php
}
?>
</table>
</div>
</body>
</html>
7. Buka localhost>latihan>perpustakaan.php<html>
<head>
<title>Perpustakaan</title>
</head>
<style>
.container{
margin: auto;
width: 900px;
}
</style>
<body>
<div class="container">
<h2>Index Buku</h2>
<table border="1" cellspacing="0" cellpadding="5">
<tr>
<th>No</th>
<th>Kode Buku</th>
<th>Judul Buku</th>
<th>Penulis</th>
<th>Penerbit</th>
<th>Tahun Terbit</th>
<th>Harga</th>
</tr>
<?php
include 'koneksi.php';
$no = 1;
$data = mysqli_query($koneksi,"SELECT * FROM buku");
while($b = mysqli_fetch_array($data)){
?>
<tr>
<td><?php echo $no++; ?></td>
<td><?php echo $b['kode_buku']; ?></td>
<td><?php echo $b['judul_buku']; ?></td>
<td><?php echo $b['penulis']; ?></td>
<td><?php echo $b['penerbit']; ?></td>
<td><?php echo $b['tahun_terbit']; ?></td>
<td><?php echo $b['harga']; ?></td>
</tr>
<?php
}
?>
</table>
</div>
</body>
</html>
8. Maka akan muncul tampilan seperti ini
Atas perhatiannya saya ucapkan terimakasih banyak
Tugas Jumat 21 Juni 2019 Aldo FH 1802003 TI D
Reviewed by Aldo FH
on
June 21, 2019
Rating:
Reviewed by Aldo FH
on
June 21, 2019
Rating:







No comments: