Professional Documents
Culture Documents
3. Tạo thư mục class và trong thư mục class tạo các tệp class.db.php và class.db.theloai.php
class DB{
private $link;
/**
* DB Class's constructor
*/
function __construct() {
global $config;
/**
* Execute a query
*/
return $result;
/**
* Fetch row
* @return boolean
*/
$row = mysqli_fetch_assoc($result);
return $row;
?>
include 'class.db.php';
function __construct() {
parent::__construct();
/**
*/
$result = $this->db_query($query);
$theloai = array();
$i = 0;
while($row = $this->db_fetch($result)){
$theloai[$i++] = $row;
return $theloai;
/**
*/
$result = $this->db_query($query);
return $result;
/**
*/
$result = $this->db_query($query);
return $result;
/**
*/
public function xoa_theloai($id){
$result = $this->db_query($query);
return $result;
?>
include 'config.php';
include 'class/class.db.theloai.php';
$theloai_arr = $db_theloai->get_theloai();
$theloai_html = "";
if(count($theloai_arr) == 0){
}else{
="10" cellspacing="0">
</tr>';
foreach($theloai_arr as $item){
$theloai_html .= '<tr>';
$theloai_html .= '<td>'.$item['TenTL'].'</td>';
$theloai_html .= '<td>'.$item['ThuTu'].'</td>';
$theloai_html .= '<td>'.$item['AnHien'].'</td>';
'.$item['idTL'].'">Sửa</a></td>';
'.$item['idTL'].
sự muốn xóa\');">Xóa</a></td>';
$theloai_html .= '</tr>';
$theloai_html .= '</table>';
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
</head>
<body>
<div class="container">
</div>
</body>
</html>
<?php
include 'config.php';
include 'class/class.db.theloai.php';
if(isset($_POST['submit'])){
if($result){
}else{
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<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>
</head>
<body>
<div class="container">
<table width="100%">
<tr>
</tr>
<tr>
</tr>
<tr>
<td>Ẩn/Hiện: </td>
<td>
<select name="an_hien">
<option value="0">Ẩn</option>
</select>
</td>
</tr>
<tr>
</tr>
</table>
</form>
</div>
</body>
</html>
include 'config.php';
include 'class/class.db.theloai.php';
if(isset($_GET['id'])){
$theloai_arr = $db_theloai->get_theloai($_GET['id']);
$ten_theloai = $theloai_arr[0]['TenTL'];
$thu_tu = $theloai_arr[0]['ThuTu'];
$an_hien = $theloai_arr[0]['AnHien'];
if(isset($_POST['submit'])){
if($result){
}else{
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<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>
</head>
<body>
<div class="container">
<table width="100%">
<tr>
</tr>
<tr>
</tr>
<tr>
<td>Ẩn/Hiện: </td>
<td>
<select name="an_hien">
<option value="1">Hiện</option>
</select>
</td>
</tr>
<tr>
</tr>
</table>
</form>
</div>
</body>
</html>
<?php
include 'class/class.db.theloai.php';
if(isset($_GET['id'])){
$id = $_GET['id'];
$result = $db_theloai->xoa_theloai($id);
if($result){
}else{
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<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>
</head>
<body>
<div class="container">
</div>
</body>
</html>