By GokiSoft.com|
15:10 13/04/2022|
Học PHP
[Video] Bài tập - Quản lý thư viên bằng PHP - C2110I
https://gokisoft.com/bai-tap-quan-ly-sinh-thu-vien-bang-php.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Quan Ly Thu Vien</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div class="container">
<table class="table table-bordered">
<thead>
<tr>
<th>No</th>
<th>Thumbnail</th>
<th>Title</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<?php
// Sinh ngau nhien 1 so tu nhien N
$N = rand(3, 15);
// Tao ngau nhien mang $bookList gom N quyen sach
$bookList = []; //Mang index -> quan ly cac phan tu -> moi 1 phan tu trong mang -> array ($key & $value)
for ($i=0; $i < $N; $i++) {
$item = [
'thumbnail' => 'https://vncoder.vn/upload/img/course/1577597211.png',
'title' => 'Quyen sach '.$i,
'price' => 1000 + 100 * $i
];
$bookList[] = $item;
}
// Hien thi
$index = 0;
foreach ($bookList as $item) {
echo '<tr>
<td>'.(++$index).'</td>
<td><img src="'.$item['thumbnail'].'" style="width: 120px;"/></td>
<td>'.$item['title'].'</td>
<td>'.$item['price'].'</td>
</tr>';
}
?>
</tbody>
</table>
</div>
</body>
</html>
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)