.

CREATE TABLE books (
    tbl_books_id INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
    tbl_books_name VARCHAR(255) NOT NULL,
    tbl_books_namewrite VARCHAR(255) NOT NULL,
    tbl_books_publisher VARCHAR(255) NOT NULL,
    tbl_books_totol VARCHAR(10) NOT NULL
)ENGINE=InnoDB DEFAULT CHARSET="utf8";
<?php
    $server = "127.0.0.1";
    $username = "root";
    $password = "";
    $dbname = "ebooks";
    $condb = mysqli_connect("$server", "$username", "$password", "$dbname");

    if(isset($_POST['btn_addbook'])){
        $sql_insert_books = "INSERT INTO `books` (`tbl_books_id`, `tbl_books_name`, `tbl_books_namewrite`, `tbl_books_publisher`, `tbl_books_totol`) VALUES ('".$_POST['tbl_books_id']."', '".$_POST['tbl_books_name']."', '".$_POST['tbl_books_namewrite']."', '".$_POST['tbl_books_publisher']."', '".$_POST['tbl_books_totol']."');";
        mysqli_query($condb, $sql_insert_books);
    }

    if(isset($_POST['btn_delete'])){
        $id = $_POST['tbl_books_id_delete'];
        $sql_delete_books = " DELETE FROM books WHERE `books`.`tbl_books_id` = $id";
        mysqli_query($condb, $sql_delete_books);
    }

    if(isset($_POST['btn_edit_save'])){
        $id_edit_save = $_POST['id_edit'];
        $sql_btn_edit_save = " UPDATE `books` SET `tbl_books_id` = '".$_POST['tbl_books_id']."', `tbl_books_name` = '".$_POST['tbl_books_name']."', `tbl_books_namewrite` = '".$_POST['tbl_books_namewrite']."', `tbl_books_publisher` = '".$_POST['tbl_books_publisher']."', `tbl_books_totol` = '".$_POST['tbl_books_totol']."' WHERE `books`.`tbl_books_id` = $id_edit_save; ";
        mysqli_query($condb, $sql_btn_edit_save);
    }
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>E-Book</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
</head>
<body>
    



<div class="container">
    <img src="logo.png" width="250px">
    <h2>ECS ***********</h2>
    <hr>
<?php
    if(isset($_POST['btn_edit'])){
        $id2 = $_POST['tbl_books_id_edit'];
        $sql_select_books_edit = " SELECT * FROM books WHERE tbl_books_id = $id2";
        $result_sql_select_books_edit = mysqli_query($condb, $sql_select_books_edit);
        foreach($result_sql_select_books_edit as $row2){
?>
<div class="modal fade" id="onload" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">แก้ไขหนังสือ</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <!-- form -->
        <form action="" method="post">
            <input type="hidden" value="<?php echo $id2; ?>" name="id_edit">
            <div class="mb-3">
                <label class="form-label">รหัสหนังสือ</label>
                <input type="number" class="form-control" name="tbl_books_id" value="<?php echo $row2["tbl_books_id"]; ?>">
            </div>
            <div class="mb-3">
                <label class="form-label">ชื่อหนังสือ</label>
                <input type="text" class="form-control" name="tbl_books_name" value="<?php echo $row2["tbl_books_name"]; ?>">
            </div>
            <div class="mb-3">
                <label class="form-label">ชื่อผู้เขียน</label>
                <input type="text" class="form-control" name="tbl_books_namewrite" value="<?php echo $row2["tbl_books_namewrite"]; ?>">
            </div>
            <div class="mb-3">
                <label class="form-label">ชื่อสำนักพิมพ์</label>
                <input type="text" class="form-control" name="tbl_books_publisher" value="<?php echo $row2["tbl_books_publisher"]; ?>">
            </div>
            <div class="mb-3">
                <label class="form-label">จำนวนเล่ม</label>
                <input type="number" class="form-control" name="tbl_books_totol" value="<?php echo $row2["tbl_books_totol"]; ?>">
            </div>
        
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">ยกเลิก</button>
        <input type="submit" class="btn btn-success" value="แก้ไข" name="btn_edit_save">
        <!-- form -->
        </form>
        <!-- form -->
      </div>
    </div>
  </div>
</div>
<?php
    }}
?>
    <!-- Button trigger modal -->
    <button type="button" class="btn btn-success" data-bs-toggle="modal" data-bs-target="#exampleModal">
    + เพิ่มหนังสือ
    </button>

    <table class="table mt-3">
        <thead>
            <tr class="text-center">
                <th scope="col">รหัสหนังสือ</th>
                <th scope="col">ชื่อหนังสือ</th>
                <th scope="col">ชื่อผู้เขียน</th>
                <th scope="col">ชื่อสำนักพิมพ์</th>
                <th scope="col">จำนวนเล่ม</th>
                <th scope="col">แก้ไข</th>
                <th scope="col">ลบ</th>
            </tr>
        </thead>
        <tbody>
<?php
    $sql_select_books = "SELECT * FROM books";
    $result_sql_select_books = mysqli_query($condb, $sql_select_books);
    foreach($result_sql_select_books as $rows){
?>
            <tr class="text-center">
                <td><?php echo $rows["tbl_books_id"];?></td>
                <td><?php echo $rows["tbl_books_name"];?></td>
                <td><?php echo $rows["tbl_books_namewrite"];?></td>
                <td><?php echo $rows["tbl_books_publisher"];?></td>
                <td><?php echo $rows["tbl_books_totol"];?></td>
                <td>
                    <form action="" method="post">
                        <input type="hidden" value="<?php echo $rows['tbl_books_id']; ?>" name="tbl_books_id_edit">
                        <input type="submit" class="btn btn-warning" value="แก้ไข" name="btn_edit">
                    </form>
                </td>
                <td>
                    <form action="" method="post">
                        <input type="hidden" value="<?php echo $rows['tbl_books_id']; ?>" name="tbl_books_id_delete">
                        <input type="submit" class="btn btn-danger" value="ลบ" name="btn_delete" onclick="return confirm('ยืนยันการลบ');">
                    </form>
                </td>
            </tr>
<?php } ?>
        </tbody>
    </table>
    
    

</div>





<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">เพิ่มหนังสือ</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <!-- form -->
        <form action="" method="post">
            <div class="mb-3">
                <label class="form-label">รหัสหนังสือ</label>
                <input type="number" class="form-control" name="tbl_books_id" required>
            </div>
            <div class="mb-3">
                <label class="form-label">ชื่อหนังสือ</label>
                <input type="text" class="form-control" name="tbl_books_name" required>
            </div>
            <div class="mb-3">
                <label class="form-label">ชื่อผู้เขียน</label>
                <input type="text" class="form-control" name="tbl_books_namewrite" required>
            </div>
            <div class="mb-3">
                <label class="form-label">ชื่อสำนักพิมพ์</label>
                <input type="text" class="form-control" name="tbl_books_publisher" required>
            </div>
            <div class="mb-3">
                <label class="form-label">จำนวนเล่ม</label>
                <input type="number" class="form-control" name="tbl_books_totol" required>
            </div>
        
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">ยกเลิก</button>
        <input type="submit" class="btn btn-success" value="เพิ่มหนังสือ" name="btn_addbook">
        <!-- form -->
        </form>
        <!-- form -->
      </div>
    </div>
  </div>
</div>


<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>

<script type="text/javascript">
    window.onload = () => {
      const myModal = new bootstrap.Modal('#onload');
      myModal.show();
    }
</script>
</body>
</html>
sudo apt update -y
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
sudo apt install docker-ce
apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update


**********
sudo vi /etc/apt/sources.list
**********
# deb cdrom:[Kubuntu 20.04 LTS _Focal Fossa_ - Release amd64 (20200423)]/ focal main multiverse restricted universe

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ focal main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ focal-updates main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ focal universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal universe
deb http://us.archive.ubuntu.com/ubuntu/ focal-updates universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://us.archive.ubuntu.com/ubuntu/ focal multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal multiverse
deb http://us.archive.ubuntu.com/ubuntu/ focal-updates multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu focal partner
# deb-src http://archive.canonical.com/ubuntu focal partner

deb http://security.ubuntu.com/ubuntu focal-security main restricted
# deb-src http://security.ubuntu.com/ubuntu focal-security main restricted
deb http://security.ubuntu.com/ubuntu focal-security universe
# deb-src http://security.ubuntu.com/ubuntu focal-security universe
deb http://security.ubuntu.com/ubuntu focal-security multiverse
# deb-src http://security.ubuntu.com/ubuntu focal-security multiverse

# This system was installed using small removable media
# (e.g. netinst, live or single CD). The matching "deb cdrom"
# entries were disabled at the end of the installation process.
# For information about how to configure apt package sources,
# see the sources.list(5) manual.
# deb http://repo.kfocus.org/ubuntu focal main
# deb-src http://repo.kfocus.org/ubuntu focal main

***************


sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo systemctl status docker

mkdir vec-utc
cd vec-utc




vi index.html
****************
<html>
<head>
<title>UTC</title>
</head>
<body>
<p>Hello world! I'am <a href="about.php">UTC</a></p>
</body>
</html> 
****************






vi Dockerfile
******************
From httpd
COPY ./ /usr/local/apache2/htdocs/
*****************


## สร้าง Database (RDS)ก่อนเอาโค้ดมาลง ใช้ FTP ที่อยู่โฟล /root/vec-utc
vi about.php

sudo docker build -t vec-utc .
docker images


## ทำหลังสร้าง SWR
docker tag vec-utc:latest swr.ap-southeast-2.myhuaweicloud.com/vec-utc1/vec-utc1:v1
docker push swr.ap-southeast-2.myhuaweicloud.com/vec-utc1/vec-utc1:v1






sudo apt install ca-certificates apt-transport-https software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.1 -y
sudo systemctl restart apache2
sudo systemctl status apache2


สร้าง VPC Peering ของ Docker กับ Database
โค้ดเปล่า ไม่เชื่อมฐานข้อมูล
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>E-Book</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
</head>
<body>
    



<div class="container">
    <img src="logo.png" width="250px">
    <h2>ECS Docker</h2>
    <hr>
<div class="modal fade" id="onload" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">แก้ไขหนังสือ</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <!-- form -->
        <form action="" method="post">
            <input type="hidden" value="<?php echo $id2; ?>" name="id_edit">
            <div class="mb-3">
                <label class="form-label">รหัสหนังสือ</label>
                <input type="number" class="form-control" name="tbl_books_id" value="<?php echo $row2["tbl_books_id"]; ?>">
            </div>
            <div class="mb-3">
                <label class="form-label">ชื่อหนังสือ</label>
                <input type="text" class="form-control" name="tbl_books_name" value="<?php echo $row2["tbl_books_name"]; ?>">
            </div>
            <div class="mb-3">
                <label class="form-label">ชื่อผู้เขียน</label>
                <input type="text" class="form-control" name="tbl_books_namewrite" value="<?php echo $row2["tbl_books_namewrite"]; ?>">
            </div>
            <div class="mb-3">
                <label class="form-label">ชื่อสำนักพิมพ์</label>
                <input type="text" class="form-control" name="tbl_books_publisher" value="<?php echo $row2["tbl_books_publisher"]; ?>">
            </div>
            <div class="mb-3">
                <label class="form-label">จำนวนเล่ม</label>
                <input type="number" class="form-control" name="tbl_books_totol" value="<?php echo $row2["tbl_books_totol"]; ?>">
            </div>
        
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">ยกเลิก</button>
        <input type="submit" class="btn btn-success" value="แก้ไข" name="btn_edit_save">
        <!-- form -->
        </form>
        <!-- form -->
      </div>
    </div>
  </div>
</div>
    <!-- Button trigger modal -->
    <button type="button" class="btn btn-success" data-bs-toggle="modal" data-bs-target="#exampleModal">
    + เพิ่มหนังสือ
    </button>

    <table class="table mt-3">
        <thead>
            <tr class="text-center">
                <th scope="col">รหัสหนังสือ</th>
                <th scope="col">ชื่อหนังสือ</th>
                <th scope="col">ชื่อผู้เขียน</th>
                <th scope="col">ชื่อสำนักพิมพ์</th>
                <th scope="col">จำนวนเล่ม</th>
                <th scope="col">แก้ไข</th>
                <th scope="col">ลบ</th>
            </tr>
        </thead>
        <tbody>
            <tr class="text-center">
                <td>tbl_books_id</td>
                <td>tbl_books_name</td>
                <td>tbl_books_namewrite</td>
                <td>tbl_books_publisher</td>
                <td>tbl_books_totol</td>
                <td>
                    <form action="" method="post">
                        <input type="hidden" value="" name="tbl_books_id_edit">
                        <input type="submit" class="btn btn-warning" value="แก้ไข" name="btn_edit">
                    </form>
                </td>
                <td>
                    <form action="" method="post">
                        <input type="hidden" value="" name="tbl_books_id_delete">
                        <input type="submit" class="btn btn-danger" value="ลบ" name="btn_delete" onclick="return confirm('ยืนยันการลบ');">
                    </form>
                </td>
            </tr>
        </tbody>
    </table>
    
    

</div>





<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">เพิ่มหนังสือ</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <!-- form -->
        <form action="" method="post">
            <div class="mb-3">
                <label class="form-label">รหัสหนังสือ</label>
                <input type="number" class="form-control" name="tbl_books_id" required>
            </div>
            <div class="mb-3">
                <label class="form-label">ชื่อหนังสือ</label>
                <input type="text" class="form-control" name="tbl_books_name" required>
            </div>
            <div class="mb-3">
                <label class="form-label">ชื่อผู้เขียน</label>
                <input type="text" class="form-control" name="tbl_books_namewrite" required>
            </div>
            <div class="mb-3">
                <label class="form-label">ชื่อสำนักพิมพ์</label>
                <input type="text" class="form-control" name="tbl_books_publisher" required>
            </div>
            <div class="mb-3">
                <label class="form-label">จำนวนเล่ม</label>
                <input type="number" class="form-control" name="tbl_books_totol" required>
            </div>
        
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">ยกเลิก</button>
        <input type="submit" class="btn btn-success" value="เพิ่มหนังสือ" name="btn_addbook">
        <!-- form -->
        </form>
        <!-- form -->
      </div>
    </div>
  </div>
</div>


<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>

</body>
</html>