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)

Phan Bạch Tùng Dương [T1907A]
Phan Bạch Tùng Dương

2020-07-01 08:46:26



<?php 
// session_start();
require_once('database.php');
?>

<!DOCTYPE html>
<html lang="en">

<head>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">

  <title>Hompage</title>

  <!-- Bootstrap core CSS -->
  <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

  <!-- Custom styles for this template -->
  <link href="css/heroic-features.css" rel="stylesheet">

    <!-- 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>

  <!-- Navigation -->
  <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
    <div class="container">
      <a class="navbar-brand" href="#">My book</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarResponsive">
        <ul class="navbar-nav ml-auto">
          <li class="nav-item active">
            <a class="nav-link" href="#">Home
              <span class="sr-only">(current)</span>
            </a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">About</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">Services</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">Contact</a>
          </li>
        </ul>
      </div>
    </div>
  </nav>

  <!-- Page Content -->
  <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
  <ol class="carousel-indicators">
    <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
  </ol>

  <div class="container">
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img class="d-block w-100" src="https://image.winudf.com/v2/image1/Y29tLlJvZ2VyT25lMjAxNy5hcHAwMTA4X3NjcmVlbl8wXzE1NTQ4NTAxNTdfMDI5/screen-0.jpg?fakeurl=1&type=.jpg" alt="First slide">
    </div>
    <div class="carousel-item">
      <img class="d-block w-100" src="https://image.winudf.com/v2/image1/Y29tLlJvZ2VyT25lMjAxNy5hcHAwMTA4X3NjcmVlbl8wXzE1NTQ4NTAxNTdfMDI5/screen-0.jpg?fakeurl=1&type=.jpg" alt="First slide" alt="Second slide">
    </div>
    <div class="carousel-item">
      <img class="d-block w-100" src="https://image.winudf.com/v2/image1/Y29tLlJvZ2VyT25lMjAxNy5hcHAwMTA4X3NjcmVlbl8wXzE1NTQ4NTAxNTdfMDI5/screen-0.jpg?fakeurl=1&type=.jpg" alt="First slide" alt="Third slide">
    </div>
  </div>
  <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>
</div>

       <form method="get">
          <input type="text" name="search" class="form-control" style="margin-top: 15px; margin-bottom: 15px;" placeholder="Tìm kiếm theo tên sản phẩm">
        </form>

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

$bookList = executeResult($sql);
      $sql = 'select * from book ';
      foreach ($bookList as $_book) {
        echo '<div class="col-lg-4 col-md-6 mb-4">
                <div class="card h-100">
                <h5 name = "title1">Bookid: '.$_book['bookid'].'</h5>
                <h5 name = "title1">Authorid: '.$_book['authorid'].'</h5>
                <h1 name = "title1">Tên sách: '.$_book['title'].'</h5>
                <h5 name = "title1">ISBN: '.$_book['ISBN'].'</h5>
                <h5 name = "title1">Năm sản xuất: '.$_book['pub_year'].'</h5>
                <h5 name = "title1">Đã bán: '.$_book['available'].'</h5>
            </div>
          </div>';   
      }
     ?>




  </div>
  <!-- /.container -->

  <!-- Footer -->
  <footer class="py-5 bg-dark">
    <div class="container">
      <p class="m-0 text-center text-white">Copyright &copy; Your Website 2020</p>
    </div>
    <!-- /.container -->
  </footer>

  <!-- Bootstrap core JavaScript -->
  <script src="vendor/jquery/jquery.min.js"></script>
  <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

</body>

</html>



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



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

/**
 * insert, update, delete -> su dung function
 */
function execute($sql) {
	//create connection toi database
	$conn = mysqli_connect(HOST, USERNAME, PASSWORD, DATABASE);

	//query
	mysqli_query($conn, $sql);

	//dong connection
	mysqli_close($conn);
}

/**
 * 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;
}



CREATE TABLE book (
 	bookid int PRIMARY KEY AUTO_INCREMENT not null,
    authorid int not null,
    title varchar(55) not null,
    ISBN varchar(25) not null,
    pub_year smallint(6) not null,
    available tinyint(4) not null
)



Đường Thanh Bình [T1907A]
Đường Thanh Bình

2020-07-01 08:46:03



<?php 
 require_once ('database.php');
 ?>
<!DOCTYPE html>
<html>
<head>
  <title>BOOK</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">
        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 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>Availbale</th>
            </tr>
          </thead>
          <thead>
            <tbody>
        <?php
        if (isset($_GET['s']) && $_GET['s'] != '') {
                  $sql = 'select * from book where title like "%'.$_GET['s'].'%"';
                     } else {
              $sql = 'select * from book';
                      }
        $bookList = executeResult($sql);
        $index = 1;
        foreach ($bookList as $book) {
            echo ' <tr>
                      <td>'.($index++).'</td>
                      <td>'.$book['authorid'].'</td>
                      <td>'.$book['title'].'</td>
                      <td>'.$book['ISBN'].'</td>
                      <td>'.$book['pub_year'].'</td>
                      <td>'.$book['available'].'</td>
         </tr>';
        }
         ?>     
            </tbody>
          </thead>
        </table>
      </div>
    </div>
  </div>
</body>
</html>



CREATE TABLE book(
	bookid int(11) PRIMARY KEY AUTO_INCREMENT not null,
    authorid int(11) not null,
    title varchar(55) not null,
    ISBN  varchar(55) not null,
    pub_year SMALLINT(6) not null,
    available tinyint(4) not null
)



<?php 
require_once('config.php');
function execute($sql){
	$con = mysqli_connect(HOST, USERNAME, PASSWORD, DATABASE);
	mysqli_query($con, $sql);
	mysqli_close($con);
}
function executeResult($sql){
	$con = mysqli_connect(HOST, USERNAME, PASSWORD, DATABASE);
	$resultset = mysqli_query($con, $sql);
	$data = [];
	while ($row = mysqli_fetch_array($resultset, 1)) {
		$data[] = $row; 
	}
	mysqli_close($con);
    return $data;
}
 ?>



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



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

2020-07-01 08:45:04

Anh Database


Đỗ Văn Huấn [T1907A]
Đỗ Văn Huấn

2020-07-01 08:44:58



CREATE TABLE librady( id int PRIMARY KEY AUTO_INCREMENT not null, 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 )



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




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

function select($sql)
{

    //mở kết nối 
    $con = mysqli_connect(HOST, USERNAME, PASSWORD, DATABASE);

    //tạo truy vấn
    $resulset = mysqli_query($con, $sql);

    // tạo mảng lưu student
    $list = array();

    while ($row = mysqli_fetch_array($resulset, 1)) {
        $list[] = $row;
    }
    // đóng kết nối
    mysqli_close($con);
    return $list;
}






<?php
require_once('manage.php');
$tr = '';
$select ='SELECT * FROM `librady`';

$bookList[] = array();

if (isset($_GET['search']) && $_GET['search'] != '') {
    $search = $_GET['search'];
    $select = 'select * from librady where title like "%' . $search . '%"';
}


$bookList = select($select);


foreach ($bookList as $book) {
    $tr .= '<tr>
        <td>' . $book['bookid'] . '</td>
        <td>' . $book['authorid'] . '</td>
        <td>' . $book['title'] . '</td>
        <td>' . $book['ISBN'] . '</td>
        <td>' . $book['pub_year'] . '</td>
        <td>' . $book['available'] . '</td>
        </tr>';
}



?>
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Librady</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.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.5.0/js/bootstrap.min.js"></script>
</head>

<body>

    <div class="container">
        <div class="container">
            <!-- Managing information book-->
            <form method="get">
                <input type="text" name="search" style="width: 500px; border:2px solid red;"  placeholder="Search by name book">
                <button type="submit" class="btn btn-primary">Search</button>
            </form>
        </div>
        <div class="container">
            <table class="table">
                <thead>
                    <tr>
                        <th>bookid</th>
                        <th>authorid</th>
                        <th>title</th>
                        <th>ISBN</th>
                        <th>pub_year</th>
                        <th>available</th>
                    </tr>
                </thead>
                <tbody>
                    <?= $tr ?>
                </tbody>
            </table>
        </div>
    </div>

</body>

</html>



Phạm Ngọc Minh [T1907A]
Phạm Ngọc Minh

2020-07-01 08:43:41


index
<?php 
 require_once ('dbhelp.php');
 ?>
<!DOCTYPE html>
<html>
<head>
	<title>Quan Ly sach</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">
				Quản lý thông tin sach
				<form method="get">
					<input type="text" name="s" 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>Availbale</th>
						</tr>
					</thead>
					<thead>
						<tbody>
				<?php
				if (isset($_GET['s']) && $_GET['s'] != '') {
	                $sql = 'select * from book where title like "%'.$_GET['s'].'%"';
                     } else {
	            $sql = 'select * from book';
                      }

				$bookList = executeResult($sql);
				$index = 1;
				foreach ($bookList as $book) {
				    echo ' <tr>
				 	            <td>'.($index++).'</td>
				 	            <td>'.$book['authorid'].'</td>
				 	            <td>'.$book['title'].'</td>
				 	            <td>'.$book['ISBN'].'</td>
				 	            <td>'.$book['pub_year'].'</td>
				 	            <td>'.$book['available'].'</td>

				 </tr>';
				}
				 ?>			

						</tbody>
					</thead>
				</table>
			</div>
		</div>
	</div>
</body>
</html>


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


dbhelp
<?php 
require_once('config.php');
function execute($sql){
	$con = mysqli_connect(HOST, USERNAME, PASSWORD, DATABASE);

	mysqli_query($con, $sql);

	mysqli_close($con);
}
function executeResult($sql){
	$con = mysqli_connect(HOST, USERNAME, PASSWORD, DATABASE);

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

	mysqli_close($con);
	
    return $data;
}

 ?>


database
CREATE TABLE book(
   bookid int PRIMARY KEY AUTO_INCREMENT not null,
   authorid int not null,
   title varchar(55) not null,
   ISBN varchar(25) not null,
   pub_year SMALLINT(6) not null,
   available tinyint(4) not null
)



Trần Anh Quân [T1907A]
Trần Anh Quân

2020-07-01 08:42:41

index.php


<?php 
 require_once ('define.php');
 ?>
<!DOCTYPE html>
<html>
<head>
	<title>Quan Ly sach</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">
				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 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>Availbale</th>
						</tr>
					</thead>
					<thead>
						<tbody>
				<?php
				if (isset($_GET['s']) && $_GET['s'] != '') {
	                $sql = 'select * from book where title like "%'.$_GET['s'].'%"';
                     } else {
	            $sql = 'select * from book';
                      }

				$bookList = executeResult($sql);
				$index = 1;
				foreach ($bookList as $book) {
				    echo ' <tr>
				 	            <td>'.($index++).'</td>
				 	            <td>'.$book['authorid'].'</td>
				 	            <td>'.$book['title'].'</td>
				 	            <td>'.$book['ISBN'].'</td>
				 	            <td>'.$book['pub_year'].'</td>
				 	            <td>'.$book['available'].'</td>

				 </tr>';
				}
				 ?>			

						</tbody>
					</thead>
				</table>
			</div>
		</div>
	</div>
</body>
</html>



hoangduyminh [T1907A]
hoangduyminh

2020-07-01 08:41:34



<?php 
 require_once ('dbhelp.php');
 ?>
<!DOCTYPE html>
<html>
<head>
	<title>Quan Ly San Pham</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">
				Quản lý thông tin sinh viên
				<form method="get">
					<input type="text" name="s" 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>Availbale</th>
						</tr>
					</thead>
					<thead>
						<tbody>
				<?php
				if (isset($_GET['s']) && $_GET['s'] != '') {
	                $sql = 'select * from book where title like "%'.$_GET['s'].'%"';
                     } else {
	            $sql = 'select * from book';
                      }

				$bookList = executeResult($sql);
				$index = 1;
				foreach ($bookList as $book) {
				    echo ' <tr>
				 	            <td>'.($index++).'</td>
				 	            <td>'.$book['authorid'].'</td>
				 	            <td>'.$book['title'].'</td>
				 	            <td>'.$book['ISBN'].'</td>
				 	            <td>'.$book['pub_year'].'</td>
				 	            <td>'.$book['available'].'</td>

				 </tr>';
				}
				 ?>			

						</tbody>
					</thead>
				</table>
			</div>
		</div>
	</div>
</body>
</html>



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



<?php 
require_once('config.php');
function execute($sql){
	$con = mysqli_connect(HOST, USERNAME, PASSWORD, DATABASE);

	mysqli_query($con, $sql);

	mysqli_close($con);
}
function executeResult($sql){
	$con = mysqli_connect(HOST, USERNAME, PASSWORD, DATABASE);

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

	mysqli_close($con);
	
    return $data;
}

 ?>



lê văn phương [T1907A]
lê văn phương

2020-07-01 08:40:58



<?php
		$hostname = "localhost";
		$user = "root";
		$pass = "";
		$db = "book";

		$con = mysqli_connect($hostname,$user,$pass,$db);
		mysqli_query($con,$db);
		mysqli_set_charset($con,"utf8");

?>



<?php
		include "config.php";
	 	$sql = "select * from book ";
	 	$result = mysqli_query($con,$sql);

?>
<!DOCTYPE html>
<html>
<head>
	<title>Assignment</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>
</head>
<body>
	<h1>hello</h1>
	


<div class="infor">
	<div class="search" style="padding-left: 22%; margin-top: 20px;">

		<?php
					include("config.php");
					if(isset($_POST["search"]))
					{
						$title_search = $_POST['nhap'];
						$sql = "select * from book where title = '$title_search'";
						mysqli_query($con,$sql);
					}else
					{
						$sql = "select * from book";
					}
					$result = mysqli_query($con,$sql);

		?>
		<form action="" method="POST" enctype="multipart/form-data">
		<tr>
			<td ><input type="text" name="nhap" size="100">
				<input type="submit" name="search" value="Tìm kiếm">
			</td>
		</tr>
	</form>
	</div>

				<table  width="900" border="1px solid #f3f3f3;" align="center" style="margin-top: 10px; text-align: center;" >
					<tr>
						<th width="50px;">bookid</th>
						<th width="50px;">authorid</th>
						<th width="200px;">title</th>
						<th width="200px;">ISBN</th>
						<th width="100px;">pub_year</th>
						<th width="100px;">available</th>
					</tr>
			<?php while ($row = mysqli_fetch_array($result)) {
				# code...
			 ?>
					<tr>
						<td><?php echo $row['bookid']; ?> </td>
						<td><?php echo $row['authorid']; ?></td>
						<td><?php echo $row['title']; ?></td>
						<td><?php echo $row['ISBN']; ?></td>
						<td><?php echo $row['pub_year']; ?></td>
						<td><?php echo $row['available']; ?></td>
						
					</tr>
			 <?php } ?>
					
				</table>
			</div>



CREATE TABLE book(
	bookid int(11) PRIMARY KEY AUTO_INCREMENT not null,
    authorid int(11) not null,
    title varchar(55) not null,
    ISBN  varchar(55) not null,
    pub_year SMALLINT(6) not null,
    available tinyint(4) not null
)



Trần Anh Quân [T1907A]
Trần Anh Quân

2020-07-01 08:40:58



<?php 
 require_once ('difine.php');
 ?>
<!DOCTYPE html>
<html>
<head>
	<title>Quan Ly sach</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">
				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 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>Availbale</th>
						</tr>
					</thead>
					<thead>
						<tbody>
				<?php
				if (isset($_GET['s']) && $_GET['s'] != '') {
	                $sql = 'select * from book where title like "%'.$_GET['s'].'%"';
                     } else {
	            $sql = 'select * from book';
                      }

				$bookList = executeResult($sql);
				$index = 1;
				foreach ($bookList as $book) {
				    echo ' <tr>
				 	            <td>'.($index++).'</td>
				 	            <td>'.$book['authorid'].'</td>
				 	            <td>'.$book['title'].'</td>
				 	            <td>'.$book['ISBN'].'</td>
				 	            <td>'.$book['pub_year'].'</td>
				 	            <td>'.$book['available'].'</td>

				 </tr>';
				}
				 ?>			

						</tbody>
					</thead>
				</table>
			</div>
		</div>
	</div>
</body>
</html>



<?php 
require_once('config.php');
function execute($sql){
	$con = mysqli_connect(HOST, USERNAME, PASSWORD, DATABASE);

	mysqli_query($con, $sql);

	mysqli_close($con);
}
function executeResult($sql){
	$con = mysqli_connect(HOST, USERNAME, PASSWORD, DATABASE);

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

	mysqli_close($con);
	
    return $data;
}

 ?>



CREATE TABLE library(
   bookid int PRIMARY KEY AUTO_INCREMENT not null,
   authorid int not null,
   title varchar(55) not null,
   ISBN varchar(25) not null,
   pub_year SMALLINT(6) not null,
   available tinyint(4) not null
)



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



Phí Văn Long [T1907A]
Phí Văn Long

2020-07-01 08:40:04


BookManager.php
<?php 
require_once('database.php');
 ?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">
  <title>HomePage SHop</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>
	<style type="text/css">
		body{
			margin-top: 100px;
		}
		a.btn.btn-danger {
		    margin-left: 15px;
		}
		p.btn.btn-success {
		    margin-top: 16px;
		}
		span.btn.btn-primary {
	    margin-left: 15px;
	}
	</style>
</head>

<body>

  <!-- Navigation -->
  <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
    <div class="container">
      <a class="navbar-brand" href="#">Shop Nong</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarResponsive">
        <ul class="navbar-nav ml-auto">
          <li class="nav-item active">
            <a class="nav-link" href="index.php">Home
              <span class="sr-only">(current)</span>
            </a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">About</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="login.php">Login</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="contact.php">Contact</a>
          </li>
        </ul>
      </div>
    </div>
  </nav>

  <!-- Page Content -->
  <div class="container">

    <div class="row">

      <div class="col-lg-3">

        <h1 class="my-4">Danh muc</h1>
        <div class="list-group">
          <a href="#" class="list-group-item">Sach thieu nhi</a>
          <a href="#" class="list-group-item">Sach tieu thuyết </a>
          <a href="#" class="list-group-item">Sách mới</a>
        </div>

      </div>
      <!-- /.col-lg-3 -->

      <div class="col-lg-9">

        <div id="carouselExampleIndicators" class="carousel slide my-4" data-ride="carousel">
          <ol class="carousel-indicators">
            <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
            <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
            <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
          </ol>
          <div class="carousel-inner" role="listbox">
            <div class="carousel-item active">
              <img class="d-block img-fluid" src="https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcQjdBYWpiOgPDEaauEMIYLRHe4f7FghColEUw&usqp=CAU" style="width: 800px; height: 300px;" alt="First slide">
            </div>
            <div class="carousel-item">
              <img class="d-block img-fluid" src="https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcRvfUhsbh0Z-M72gJB9GGKY53E-lnFeSQrvGQ&usqp=CAU" style="width: 800px; height: 300px;" alt="Second slide">
            </div>
            <div class="carousel-item">
              <img class="d-block img-fluid" src="https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcQVCObdmKcVmSbMkSP934Er0blMQGUINLHclg&usqp=CAU" style="width: 800px; height: 300px;" alt="Third slide">
            </div>
          </div>
          <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
            <span class="carousel-control-prev-icon" aria-hidden="true"></span>
            <span class="sr-only">Previous</span>
          </a>
          <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
            <span class="carousel-control-next-icon" aria-hidden="true"></span>
            <span class="sr-only">Next</span>
          </a>
        </div>
<form method="get">
					<input type="text" name="search" class="form-control" style="margin-top: 15px; margin-bottom: 15px;" placeholder="Tìm kiếm theo tên sản phẩm">
				</form>
        <div class="row">
		<?php 
		if (isset($_GET['search']) && $_GET['search'] != '') {
							$sql = 'select * from libraby where title like "%'.$_GET['search'].'%"';
						} else {
							$sql = 'select * from libraby ';
						}
			
			$BookList = executeResult($sql);
			foreach ($BookList as $book) {
				echo '<div class="col-lg-4 col-md-6 mb-4">
        		<div class="card h-100" style="text-align:center;>
        			<a href="#">Book ID :'.$book['bookid'].'</a>
        			<div class="card-body">
        			<h2 style="color:red;" class="card-text" name = "title1">Tên sách :'.$book['title'].'</h2>
        				<h4 class="card-title">
        					ID AUthor :<a href="#" name="nameproduct1">'.$book['authorid'].'</a>
        				</h4>
        				<h5 name = "price1">ISBN :'.$book['ISBN'].'</h5>
        				
        				<h5 class="card-text">Năm sản xuất :'.$book['pub_year'].'</h5>
        				<h5 class="card-text">Đã bán :'.$book['available'].'</h5>
        			</div>
        		</div>
        	</div>';
			}
		 ?>

        <!-- /.row -->

      </div>
      <!-- /.col-lg-9 -->

    </div>
    <!-- /.row -->

  </div>
  <!-- /.container -->

  <!-- Footer -->
  <footer class="py-5 bg-dark">
    <div class="container">
      <p class="m-0 text-center text-white">Copyright &copy; Your Nong</p>
    </div>
    <!-- /.container -->
  </footer>
  <script src="vendor/jquery/jquery.min.js"></script>
  <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

</body>

</html>



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



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

/**
 * insert, update, delete -> su dung function
 */
function execute($sql) {
	//create connection toi database
	$conn = mysqli_connect(HOST, USERNAME, PASSWORD, DATABASE);

	//query
	mysqli_query($conn, $sql);

	//dong connection
	mysqli_close($conn);
}

/**
 * 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;
}
 ?>



CREATE TABLE libraby(
	bookid int PRIMARY KEY AUTO_INCREMENT not null,
    authorid int not null,
    title varchar(55) not null,
	ISBN varchar(25) not null,
    pub_year SMALLINT(6) not null,
    available tinyint(4) not null
)



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

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