Code Monkey home page Code Monkey logo

book_for_rent's Introduction

Book_for_rent

Tutorial

https://www.youtube.com/watch?v=Ev3--3aX2X0

Aws Tutorial Document

https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Tutorials.WebServerDB.CreateWebServer.html

ตัวอย่าง เว็บไซต์ที่นำขึ้น Cloud .𖥔 ݁ 🪐˖

Start!

Example: Connect to instance ssh -i "php-website.pem" [email protected]

Built With 🕶


icon
MySQL
icon
Github
HTML5
HTML5
css
CSS
bootstrap
Bootstrap
bootstrap
PHP
aws
AWS
Laravel
Laravel


Cloud Class

https://www.awsacademy.com/vforcesite/LMS_Login



สร้าง Laravel

  • คำสั่งรัน php artisan serve
ตรวจสอบว่าโหลด Composer มาหรือยัง ด้วยคำสั่ง composer --version ถ้าไม่มีให้ติดตั้ง ==> https://getcomposer.org/

คำสั่งสร้าง Project ==> composer create-project laravel/laravel:^10.0 book_for_rent

กรณี Clone ==> composer install


วิธีเข้าแก้ไฟล์ใน AWS ☃︎

sudo -i เพื่อเข้าสู่ root

cd /var/www/html/

vi SamplePage.php

  • กด esc ก่อนแล้ว พิม :wq เพื่อ save แล้วออก
  • ถ้าอยากลบทุกบรรทัด ให้กด esc แล้ว :%d

วิธีเข้าสู่ฐานข้อมูล 🍹

ดูใน RDS หา php endpoint เช่น php-database.c16ycg4m0nwv.us-east-1.rds.amazonaws.com

vi db.inc.php แล้วเพิ่มโค้ดด้านล่าง เปลี่ยนค่าตามที่ตัวเองได้สร้างไว้

<?php
define('DB_SERVER', '<php endpoint>');
define('DB_USERNAME', '<user>');
define('DB_PASSWORD', '<master password>');
define('DB_DATABASE', 'php');
?>

cat db.inc.php (เช็กว่าถูกไหม)

วิธีเข้าพื้นที่จัดการ dB

mysql -u admin -h <php endpoint> -p

  • คำสั่ง แสดงฐานข้อมูลที่มี ในตอนนี้
show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| php                |
| sys                |
+--------------------+
mysql> SELECT * FROM orders;
+----------+---------+---------+----------+-------------+---------------------+
| order_id | user_id | book_id | quantity | total_price | order_date          |
+----------+---------+---------+----------+-------------+---------------------+
|        5 |       1 |       2 |        3 |       45.67 | 2024-03-12 22:33:11 |
+----------+---------+---------+----------+-------------+---------------------+
mysql> SELECT * FROM USERS;
+---------+----------+----------+-----------------+
| user_id | username | password | email           |
+---------+----------+----------+-----------------+
|       1 | girl     | 1111     | [email protected] |
|       2 | boy      | 1111     | [email protected]   |
+---------+----------+----------+-----------------+

เราต้องเข้าใน ฐานข้อมูล php ก่อน คำสั่งเข้าฐานข้อมูล = use php

  • คำสั่ง สร้าง Table ชื่อ BOOKS
USE php;
CREATE TABLE BOOKS (
    book_id INT PRIMARY KEY AUTO_INCREMENT,
    title VARCHAR(255),
    author VARCHAR(100),
    category VARCHAR(50),
    price DECIMAL(10, 2),
    cover_image_path VARCHAR(255),
    description VARCHAR(255)
);
  • คำสั่ง สร้างตาราง ORDERS
USE php;
CREATE TABLE orders (
    order_id INT PRIMARY KEY AUTO_INCREMENT,
    user_id INT,
    book_id INT,
    quantity INT DEFAULT 1,
    total_price DECIMAL(10, 2),
    order_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (user_id) REFERENCES USERS(user_id),
    FOREIGN KEY (book_id) REFERENCES BOOKS(book_id)
);
  • คำสั่ง สร้างตาราง USERS
USE php;
CREATE TABLE USERS (
    user_id INT PRIMARY KEY AUTO_INCREMENT,
    username VARCHAR(50),
    password VARCHAR(255),
    email VARCHAR(100)
);
  • คำสั่ง ดูรายละเอียด ของตารางชื่อ BOOKS
DESCRIBE BOOKS;
  • คำสั่ง เพิ่มข้อมูล ลงในตาราง BOOKS
INSERT INTO BOOKS (title, category, price, author, cover_image_path, description) VALUES 
('The girl and the Witchs Garden', 'Fantasy', 200.00, 'Erin BowMan', 'https://images-na.ssl-images-amazon.com/images/S/compressed.photo.goodreads.com/books/1570732371i/44779631.jpg', 'The owner of the estate and Piper’s wealthy grandmother—is a witch. The grand house and its garden hold many secrets—some of which may even save her father—and Piper will need to believe in herself.'),
('The CERULEAN', 'Fantasy', 250.00, 'Amy Ewing', 'https://devouringbooks2017.files.wordpress.com/2018/12/The-Cerulean-by-Amy-Ewing.jpg', 'Sera has always felt as if she didn’t belong among her people, the Cerulean. She is curious about everything and can’t stop questioning her three mothers, her best friend, Leela, and even the High Priestess');
INSERT INTO USERS (user_id, username, password, email) VALUES 
(1, 'girl', '1111',  '[email protected]'),
(2, 'boy', '1111',  '[email protected]');
  • คำสั่ง อ่าน ตาราง BOOKS
SELECT * FROM BOOKS;
USE php;
  • คำสั่ง แสดงตารางทั้งหมดที่มี ในฐานข้อมูลที่ชื่อ php
USE php;
show tables;
  • คำสั่ง Update UPDATE USERS SET email = '[email protected]' WHERE user_id = 2;

  • ⚠️⚠️ คำสั่ง ลบตาราง

DROP TABLE IF EXISTS _<tableName>_;
  • คำสั่งออก จากโหมดแก้ไขฐานข้อมูล 🧀 exit;

อ้างอิง

https://www.geeksforgeeks.org/how-to-call-php-function-on-the-click-of-a-button/

https://www.w3schools.com/php/

https://getbootstrap.com/docs/5.3/helpers/stacks/#horizontal

https://ckeditor.com/docs/ckeditor5/latest/installation/index.html

https://www.iconfinder.com/search?q=book


All Repositories

book_for_rent's People

Contributors

intummadee avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.