By GokiSoft.com| 10:14 30/10/2021|
Học PHP

[Examination] Thi kết thuc môn PHP - Thi Thực Hành - Đề 2




Phản hồi từ học viên

5

(Dựa trên đánh giá ngày hôm nay)

NguyenHuuThanh [T1907A]
NguyenHuuThanh

2020-07-01 08:39:15



config.php
<?php
define('HOST' , 'localhost');
define('DATABASE' , 'library');
define('USERNAME' , 'root');
define('PASSWORD' , '');

dbhelper.php
<?php
require_once ('config.php');


/**
 * su dung cho lenh select => tra ve ket qua
 */
function executeResult($sql) {
	//create connection toi database
	$conn = mysqli_connect(HOST, USERNAME, PASSWORD, DATABASE);

	//query
	$resultset = mysqli_query($conn, $sql);
	$list      = [];
	while ($row = mysqli_fetch_array($resultset, 1)) {
		$list[] = $row;
	}

	//dong connection
	mysqli_close($conn);

	return $list;
}

Book.php
<?php
require_once('dbhelper.php');
?>

<!DOCTYPE html>
<html>
<head>
	<title> Book Management </title>

	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

	<!-- jQuery library -->
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

	<!-- Popper JS -->
	<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>

	<!-- Latest compiled JavaScript -->
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>


</head>
<body>

	<div class = "container bg-secondary text-white">
		<div class = "panel panel-primary">
			<div class = "panel-heading">
				<h1 class ="text-center" >Book Management </h1> 
			<form method="get">
					<input type="text" name="s" class="form-control" style="margin-top: 15px; margin-bottom: 15px;" placeholder="Find by name">
				</form>
			</div>
			<div class="panel-body">
				<table class="table table-bordered text-white">
					<thead>
						<tr>
							<th>BookID</th>
							<th>AuthorID</th>
							<th>Title</th>
							<th>ISBN</th>
							<th>Pub_year</th>
							<th>Available</th>
						</tr>
					</thead>
					<tbody>

    </div>

    <?php

// TIm kiem : 
if (isset($_GET['s']) && $_GET['s'] != '') {
	$sql = 'select * from book where title like "%'.$_GET['s'].'%"';
} else {
	$sql = 'select * from book';
}

$bookList = executeResult($sql);

$bookid = 1;
foreach ($bookList as $bk) {
	echo '<tr>
			
			<td>'.($bookid++).'</td>
			<td>'.$bk['authorid'].'</td>
			<td>'.$bk['title'].'</td>
			<td>'.$bk['ISBN'].'</td>
			<td>'.$bk['pub_year'].'</td>
			<td>'.$bk['available'].'</td>
			
			
		</tr>';
}
?>
					</tbody>
				</table>
				
			</div>
		</div>
	</div>

</body>
</html>



Thành Lâm [T1907A]
Thành Lâm

2020-07-01 08:38:26



<?php
require_once ('dbhelp.php');
?>
<!DOCTYPE html>
<html>
<head>
	<title>Quản lý Sách</title>

	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

	<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>

	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</head>
<body>
	<div class="container">
		<div class="panel panel-primary">
			<div class="panel-heading">
				Quản lý Sách
				<form method="get">
					<input type="text" name="s" class="form-control" style="margin-top: 15px; margin-bottom: 15px;" placeholder="Tìm kiếm tên sách">
				</form>
			</div>
			<div class="panel-body">
				<table class="table table-bordered">
					<thead>
						<tr>
							<th>STT</th>
							<th>Tên Sách</th>
							<th>Năm phát hành</th>
							<th>Tác giả</th>
							<th width="60px"></th>
							<th width="60px"></th>
						</tr>
					</thead>
					<tbody>
<?php
if (isset($_GET['s']) && $_GET['s'] != '') {
	$sql = 'select * full textbook"%'.$_GET['s'].'%"';
} else {
	$sql = 'select * from book';
}

$studentList = executeResult($sql);

$index = 1;
foreach ($studentList as $std) {
	echo '<tr>
			<td>'.($index++).'</td>
			<td>'.$std['fullname'].'</td>
			<td>'.$std['age'].'</td>
			<td>'.$std['address'].'</td>
			<td><button class="btn btn-warning" onclick=\'window.open("input.php?id='.$std['id'].'","_self")\'>Edit</button></td>
			<td><button class="btn btn-danger" onclick="delete_book('.$std['id'].')">Delete</button></td>
		</tr>';
}
?>
					</tbody>
				</table>
				<button class="btn btn-success" onclick="window.open('input.php', '_self')">Add Book</button>
			</div>
		</div>
	</div>


</body>
</html>



<?php
require_once ('dbhelp.php');

$s_fullname = $s_age = $s_address = '';

if (!empty($_POST)) {
	$s_id = '';

	if (isset($_POST['fullname'])) {
		$s_fullname = $_POST['fullname'];
	}

	if (isset($_POST['age'])) {
		$s_age = $_POST['age'];
	}

	if (isset($_POST['address'])) {
		$s_address = $_POST['address'];
	}

	if (isset($_POST['id'])) {
		$s_id = $_POST['id'];
	}

	$s_fullname = str_replace('\'', '\\\'', $s_fullname);
	$s_age      = str_replace('\'', '\\\'', $s_age);
	$s_address  = str_replace('\'', '\\\'', $s_address);
	$s_id       = str_replace('\'', '\\\'', $s_id);

	if ($s_id != '') {
		$sql = "update student set fullname = '$s_fullname', age = '$s_age', address = '$s_address' where id = " .$s_id;
	} else {
		$sql = "insert into student(fullname, age, address) value ('$s_fullname', '$s_age', '$s_address')";
	}


	execute($sql);

	header('Location: index.php');
	die();
}

$id = '';
if (isset($_GET['id'])) {
	$id          = $_GET['id'];
	$sql         = 'select * from student where id = '.$id;
	$studentList = executeResult($sql);
	if ($studentList != null && count($studentList) > 0) {
		$std        = $studentList[0];
		$s_fullname = $std['fullname'];
		$s_age      = $std['age'];
		$s_address  = $std['address'];
	} else {
		$id = '';
	}
}
?>

<!DOCTYPE html>
<html>
<head>
	<title>Sign up for the book</title>

	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

	<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>

	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</head>
<body>
	<div class="container">
		<div class="panel panel-primary">
			<div class="panel-heading">
				<h2 class="text-center">Add Book</h2>
			</div>
			<div class="panel-body">
				<form method="post">
					<div class="form-group">
					  <label for="usr">Name Book:</label>
					  <input type="number" name="id" value="<?=$id?>" style="display: none;">
					  <input required="true" type="text" class="form-control" id="usr" name="fullname" value="<?=$s_fullname?>">
					</div>
					<div class="form-group">
					  <label for="birthday">Năm xuất bản:</label>
					  <input type="number" class="form-control" id="age" name="age" value="<?=$s_age?>">
					</div>
					<div class="form-group">
					  <label for="address">Tác giả:</label>
					  <input type="text" class="form-control" id="address" name="address" value="<?=$s_address?>">
					</div>
					<button class="btn btn-success">Save</button>
				</form>
			</div>
		</div>
	</div>
</body>
</html>



<?php
define('HOST', 'localhost');
define('DATABASE', 'quan_ly_sach');
define('USERNAME', 'root');
define('PASSWORD', '');
?>



<?php
require_once ('quan_ly_sach.php');

function execute($sql) {

	$conn = mysqli_connect(HOST, USERNAME, PASSWORD, DATABASE);

	mysqli_query($conn, $sql);


	mysqli_close($conn);
}

function executeResult($sql) {

	$conn = mysqli_connect(HOST, USERNAME, PASSWORD, DATABASE);


	$resultset = mysqli_query($conn, $sql);
	$list      = [];
	while ($row = mysqli_fetch_array($resultset, 1)) {
		$list[] = $row;
	}

	mysqli_close($conn);

	return $list;
}
?>



nguyễn văn huy [T1907A]
nguyễn văn huy

2020-07-01 08:36:48



<?php
define('HOST', 'localhost');
define('DATABASE', 'books');
define('USERNAME', 'root');
define('PASSWORD', '');
>>>>>>>>
<?php
require_once ('config.php');

function execute($sql) {
	$conn = mysqli_connect(HOST, USERNAME, PASSWORD, DATABASE);
	mysqli_query($conn, $sql);
	mysqli_close($conn);
}
function executeResult($sql) {
	$conn = mysqli_connect(HOST, USERNAME, PASSWORD, DATABASE);
	$resultset = mysqli_query($conn, $sql);
	$list      = [];
	while ($row = mysqli_fetch_array($resultset, 1)) {
		$list[] = $row;
	}
	mysqli_close($conn);

	return $list;
}
>>>>
<?php
require_once ('dbhelp.php');
?>
<!DOCTYPE html>
<html>
<head>
	<title>Student Management</title>
	<!-- Latest compiled and minified CSS -->
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

	<!-- jQuery library -->
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

	<!-- Popper JS -->
	<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>

	<!-- Latest compiled JavaScript -->
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</head>
<body>
	<div class="container">
		<div class="panel panel-primary">
			<div class="panel-heading">
				Book
				<form method="get">
					<input type="text" name="s" class="form-control" style="margin-top: 15px; margin-bottom: 15px;" placeholder="Tìm kiếm theo title">
				</form>
			</div>
			<div class="panel-body">
				<table class="table table-bordered">
					<thead>
						<tr>
							
							<th>bookid</th>
							<th>authorid</th>
							<th>title</th>
							<th>ISBN</th>
							<th>pub_year</th>
							<th>avallable</th>
						</tr>
					</thead>
					<tbody>
<?php
if (isset($_GET['s']) && $_GET['s'] != '') {
	$sql = 'select * from bookss where title like "%'.$_GET['s'].'%"';
} else {
	$sql = 'select * from bookss';
}

$studentList = executeResult($sql);

$bookid = 1;
foreach ($studentList as $std) {
	echo '<tr>
			
			<td>'.($bookid++).'</td>
			<td>'.$std['authorid'].'</td>
			<td>'.$std['title'].'</td>
			<td>'.$std['ISBN'].'</td>
			<td>'.$std['pub_year'].'</td>
			<td>'.$std['avallable'].'</td>
		</tr>';
}
?>
					</tbody>
				</table>
			</div>
		</div>
	</div>
</body>
</html>



Luong Dinh Dai [T1907A]
Luong Dinh Dai

2020-07-01 08:31:12


#book.sql


-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jul 01, 2020 at 10:26 AM
-- Server version: 10.4.13-MariaDB
-- PHP Version: 7.4.7

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `thuchanh`
--

-- --------------------------------------------------------

--
-- Table structure for table `book`
--

CREATE TABLE `book` (
  `bookid` int(11) NOT NULL,
  `authorid` int(11) NOT NULL,
  `title` varchar(55) NOT NULL,
  `ISBN` varchar(25) NOT NULL,
  `pub_year` smallint(6) NOT NULL,
  `available` tinyint(4) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `book`
--

INSERT INTO `book` (`bookid`, `authorid`, `title`, `ISBN`, `pub_year`, `available`) VALUES
(1, 1, 'fsas', '00001', 2006, 6),
(2, 2, 'gkai ka', '000002', 2011, 2),
(3, 3, 'dsf ka', '000003', 2013, 6),
(4, 4, 'gi 13', '00004', 2018, 4),
(5, 5, 'gka bma', '00005', 2007, 2),
(6, 6, 'fa g', '00006', 2001, 3);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `book`
--
ALTER TABLE `book`
  ADD PRIMARY KEY (`bookid`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `book`
--
ALTER TABLE `book`
  MODIFY `bookid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;


#dbmysql.php


<?php
define('HOST', 'localhost');
define('DATABASE', 'thuchanh');
define('USERNAME', 'root');
define('PASSWORD', '');

function execute($sql) {


	$connect = mysqli_connect(HOST, USERNAME, PASSWORD, DATABASE);

	mysqli_query($connect, $sql);

	if ($connect->connect_error) {
		var_dump($connect->connect_error);
		die();
	}
	mysqli_close($connect);
}

function execute_result($sql) {

	$resultList = array();
	$connect = mysqli_connect(HOST, USERNAME, PASSWORD, DATABASE);

	$resultset = mysqli_query($connect, $sql);
	while ($row = mysqli_fetch_array($resultset, 1)) {
		$resultList[] = $row;
	}

	mysqli_close($connect);

	return $resultList;
}


#showbook.php


<?php
require_once 'dbmysql.php';

?>
<!DOCTYPE html>
<html>
<head>
	<title>Student Management</title>
	<!-- Latest compiled and minified CSS -->
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

	<!-- jQuery library -->
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

	<!-- Popper JS -->
	<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>

	<!-- Latest compiled JavaScript -->
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</head>
<body>
	<div class="container">
		<div class="panel panel-primary">
			<div class="panel-heading">
				<form method="get">
					<input type="text" name="timkiem" class="form-control" style="margin-top: 15px; margin-bottom: 15px;" placeholder="Tìm kiếm theo tên">
				</form>
			</div>
			<div class="panel-body">
				<table class="table table-bordered">
					<thead>
						<tr>
							<th>BookID</th>
							<th>AuthorID</th>
							<th>title</th>
							<th>ISBN</th>
							<th>pub_year</th>
							<th>available</th>
						</tr>
					</thead>
					<tbody>
						<?php
if (isset($_GET['timkiem']) && $_GET['timkiem'] != '') {
	$sql = 'select * from Book where title like "%' . $_GET['timkiem'] . '%"';
} else {
	$sql = 'select * from Book';
}

$listBook = execute_result($sql);
foreach ($listBook as $value) {
	echo '<tr>
							<td>' . $value['bookid'] . '</td>
							<td>' . $value['authorid'] . '</td>
							<td>' . $value['title'] . '</td>
							<td>' . $value['ISBN'] . '</td>
							<td>' . $value['pub_year'] . '</td>
							<td>' . $value['available'] . '</td>
							</tr>';
}
?>
					</tbody>
				</table>

			</div>
		</div>
	</div>
</body>
</html>



Trần Mạnh Dũng [T1907A]
Trần Mạnh Dũng

2020-07-01 08:29:04


#library.sql


-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Máy chủ: 127.0.0.1
-- Thời gian đã tạo: Th7 01, 2020 lúc 10:23 AM
-- Phiên bản máy phục vụ: 10.4.11-MariaDB
-- Phiên bản PHP: 7.4.4

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Cơ sở dữ liệu: `aptechlib`
--

-- --------------------------------------------------------

--
-- Cấu trúc bảng cho bảng `library`
--

CREATE TABLE `library` (
  `bookid` int(11) NOT NULL,
  `authorid` int(11) NOT NULL,
  `title` varchar(55) COLLATE utf8mb4_unicode_ci NOT NULL,
  `ISBN` varchar(6) COLLATE utf8mb4_unicode_ci NOT NULL,
  `pub_year` smallint(6) NOT NULL,
  `available` tinyint(4) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Đang đổ dữ liệu cho bảng `library`
--

INSERT INTO `library` (`bookid`, `authorid`, `title`, `ISBN`, `pub_year`, `available`) VALUES
(1, 1, 'book is my life', '123456', 3, 4),
(2, 2, 'rick kid', '123', 5, 23),
(3, 4, 'abc', '1234', 12, 23),
(4, 12, 'fpt aptech', '324', 43, 54),
(5, 13, 'T1907A', '999', 99, 9);

--
-- Chỉ mục cho các bảng đã đổ
--

--
-- Chỉ mục cho bảng `library`
--
ALTER TABLE `library`
  ADD PRIMARY KEY (`bookid`);

--
-- AUTO_INCREMENT cho các bảng đã đổ
--

--
-- AUTO_INCREMENT cho bảng `library`
--
ALTER TABLE `library`
  MODIFY `bookid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;


#booklist.php


<?php
require_once ('dbhelper.php');
?>
<!DOCTYPE html>
<html>

<head>
    <title>Library</title>
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

    <!-- jQuery library -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

    <!-- Popper JS -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>

    <!-- Latest compiled JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>

</head>

<body>
    <div class="container">
        <div class="panel-body text-center pt-5">
            <h3> FPT Aptech Library</h3>
            <form class="pt-3" method="get">
                <input type="text" name="search" class="form-control" style="margin-top: 15px; margin-bottom: 15px;"
                    placeholder="Search for book by title">
            </form>
            <table class="table">
                <thead>
                    <tr>
                        <th>Book ID</th>
                        <th>Author ID</th>
                        <th>Title</th>
                        <th>ISBN</th>
                        <th>Pub_Year</th>
                        <th>Available</th>
                    </tr>
                </thead>
                <tbody>
                    <?php
if (isset($_GET['search']) && $_GET['search'] != '') {
	$sql = 'select * from library where title like "%'.$_GET['search'].'%"';
} else {
	$sql = 'select * from library';
}

$bookList = executeResult($sql);
foreach ($bookList as $row) {
    echo '<tr>
            <td>'.$row['bookid'].'</td>
			<td>'.$row['authorid'].'</td>
            <td>'.$row['title'].'</td>
            <td>'.$row['ISBN'].'</td>
            <td>'.$row['pub_year'].'</td>
            <td>'.$row['available'].'</td>
		</tr>';
}
?>
                </tbody>
            </table>
        </div>
    </div>
</body>

</html>


#dbhelper.php


<?php

define('HOST', 'localhost');
define('DATABASE', 'aptechlib');
define('USERNAME', 'root');
define('PASSWORD', '');

function execute($sql) {

	$conn = mysqli_connect(HOST, USERNAME, PASSWORD, DATABASE);

	mysqli_query($conn, $sql);

	mysqli_close($conn);
}
function executeResult($sql) {

	$conn = mysqli_connect(HOST, USERNAME, PASSWORD, DATABASE);

	$resultset = mysqli_query($conn, $sql);
	$list      = [];
	while ($row = mysqli_fetch_array($resultset, 1)) {
		$list[] = $row;
	}

	mysqli_close($conn);

	return $list;
}



thienphu [T1907A]
thienphu

2020-07-01 08:27:51


#database.php


<?php
define('HOST', 'localhost');
define('DATABASE', 'quanlysanpham');
define('USERNAME', 'root');
define('PASSWORD', '');

function execute($sql) {

	$connect = mysqli_connect(HOST, USERNAME, PASSWORD, DATABASE);

	mysqli_query($connect, $sql);

	if ($connect->connect_error) {
		var_dump($connect->connect_error);
		die();
	}
	mysqli_close($connect);
}

function execute_result($sql) {

	$resultList = array();
	$connect = mysqli_connect(HOST, USERNAME, PASSWORD, DATABASE);

	$resultset = mysqli_query($connect, $sql);
	while ($row = mysqli_fetch_array($resultset, 1)) {
		$resultList[] = $row;
	}

	mysqli_close($connect);

	return $resultList;
}


#displaybook.php


<?php
require_once 'database.php';
if (isset($_GET['timkiem']) && $_GET['timkiem'] != '') {
	$sql = 'select * from structure where title like "%' . $_GET['timkiem'] . '%"';
} else {
	$sql = 'select * from structure';
}

$listBook = execute_result($sql);
?>
<!DOCTYPE html>
<html>
<head>
	<title>Book Management</title>
	<!-- Latest compiled and minified CSS -->
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

	<!-- jQuery library -->
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

	<!-- Popper JS -->
	<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>

	<!-- Latest compiled JavaScript -->
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</head>
<body>

	<div class="container" >
		<h1 style="color:red;margin-top: 50px; margin-bottom: 50px;"><center>Manage Books</center></h1>
		<div class="panel panel-primary">
			<div class="panel-heading">
				Search for books by name
				<form method="get">
					<input type="text" name="timkiem" class="form-control" style="margin-top: 15px; margin-bottom: 15px;" placeholder="Tìm kiếm theo tên">
				</form>
			</div>
			<div class="panel-body">
				<table class="table table-bordered">
					<thead>
						<tr>

							<th>BookID</th>
							<th>AuthorID</th>
							<th>title</th>
							<th>ISBN</th>
							<th>pub_year</th>
							<th>available</th>
						</tr>
					</thead>
					<tbody>
						<?php

foreach ($listBook as $value) {
	echo '<tr>

							<td>' . $value['bookid'] . '</td>
							<td>' . $value['authorid'] . '</td>
							<td>' . $value['title'] . '</td>
							<td>' . $value['ISBN'] . '</td>
							<td>' . $value['pub_year'] . '</td>
							<td>' . $value['available'] . '</td>

							</tr>';
}
?>
					</tbody>
				</table>

			</div>
		</div>
	</div>


</body>
</html>


#structure.sql


-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jul 01, 2020 at 10:26 AM
-- Server version: 10.4.11-MariaDB
-- PHP Version: 7.4.5

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `quanlysanpham`
--

-- --------------------------------------------------------

--
-- Table structure for table `structure`
--

CREATE TABLE `structure` (
  `bookid` int(11) NOT NULL,
  `authorid` int(11) NOT NULL,
  `title` varchar(55) NOT NULL,
  `ISBN` varchar(25) NOT NULL,
  `pub_year` smallint(6) NOT NULL,
  `available` tinyint(4) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `structure`
--

INSERT INTO `structure` (`bookid`, `authorid`, `title`, `ISBN`, `pub_year`, `available`) VALUES
(1, 1, 'love you', 'ISBN01', 2020, 3),
(2, 2, 'kiss you', 'ISBN02', 2019, 2),
(3, 3, 'my live', 'ISBN03', 2018, 1),
(4, 4, 'karama', 'ISBN04', 2019, 2),
(5, 5, 'kiss you', 'ISBN05', 2019, 5),
(6, 6, 'tokyo hot', 'ISBN06', 2020, 10),
(7, 7, 'Cristiano Ronaldo', 'ISBN07', 2020, 2),
(8, 8, 'Messi no 1', 'ISBN08', 2020, 1);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `structure`
--
ALTER TABLE `structure`
  ADD PRIMARY KEY (`bookid`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `structure`
--
ALTER TABLE `structure`
  MODIFY `bookid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;



Đăng nhập để làm bài kiểm tra

Chưa có kết quả nào trước đó