1. Trang chủ
  2. » Công Nghệ Thông Tin

Tổng hợp bài thảo luận Thiết kế web phần PHP

32 93 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 32
Dung lượng 21,53 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Cho cơ sở dữ liệu QL_SP (quản sản phẩm) trên máy chủ cơ sở dữ liệu MySQL (với tên đăng nhập là root mật khẩu là 133456) đặt tại máy có tên máy là MAY10 như sau: Hãy tạo 1 trang web bằng ngôn ngữ PHP để tìm kiếm sản phẩm theo loại như hình dưới đây, trong đó:  Ô Select Loại sản phẩm có nguồn là bảng LOAISANPHAM.  Khi người dùng chọn một loại sản phẩm bất kỳ và click vào nút lệnh ‘Tìm’ thì tất cả các sản phẩm của loại đó sẽ được liệt kê theo các thông tin như trong bảng.

Trang 1

Nhóm 1

<html lang="vi">

<head>

<title>Bài thảo luận</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

$connect = new mysqli($server, $username, $password, $dbname);

$sql = "SELECT * FROM loaisanpham";

$query = mysqli_query($connect,$sql);

echo "<select name = 'Loai'>";

for ($i = 0; $i < mysqli_num_rows($query); $i++) {

Trang 3

</html>

Trang 4

<title>Đề tài 2</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Trang 5

<tr>

<td align = "right"> Mã điện thoại </td>

<td><input type="text" name='madienthoai' value="<?php echo $madienthoai;?>"> </tr>

<tr>

<td align = "right"> Tên điện thoại </td>

<td><input type="text" name='tendienthoai'value="<?php echo $tendienthoai;?>"> </tr>

<tr>

<td align = "right"> Tính năng </td>

<td><textarea type="text" name='tinhnang'><?php echo $tinhnang;?></textarea> </tr>

echo "<select name = 'hangdt'>";

for ($i = 0; $i < mysqli_num_rows($query); $i++) {

Trang 7

echo"<td><a href='Đề tài 2.php?Madienthoai=".$row['Madienthoai']."'>detail</a></td>";

Mysql_select_db(“QL_HANG” , $connect)or die( “Không tìm thấy CSDL”)

$result_all=mysql_query(‘select*from ‘dienthoai’,’loai’ where ‘dienthoai’,’maloai’=’loai’,’maloai’’); $result_loai=mysql_query(“select * from ‘loai’ “);

Trang 10

Mã sách <input type="text" name='masach' value=""><br>

Tên sách<input type="text" name='tensach' value=""><br>

Tác giả<input type="text" name='tacgia' value=""><br>

Nhà xuất bản<input type="text" name='nxb' value=""><br>

Giá<input type="text" name='gia' value=""><br>

Trang 11

echo"<td width='20%'>Tác giả</td>";

echo"<td width='20%'>Nhà xuất bản</td>";

echo"<td width='10%'>Giá</td>";

echo"<td width='10%'>Thể loại</td>";

Trang 12

echo "<td width='10%'>".$rc['theloai']."</td>"; echo "</tr>";

Trang 13

Mã sách?<input type="text" name='masach' value=""><br>

Tên sách<input type="text" name='tensach' value=""><br>

Tác gi?<input type="text" name='tacgia' value=""><br>

Nhà xu?t b?n<input type="text" name='nxb' value=""><br>

Giá<input type="text" name='gia' value=""><br>

Trang 16

<form action="trom.php" method="post">

Mã sách<input type="text" name="masach" /><br> Thể loại<select name="theloai">

Trang 18

<title> Quản lý điện thoại </title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Trang 19

<td><input type = 'text' name = 'mdt' value = <?php echo $_REQUEST['rmdt'];?>></td>

</tr>

<tr>

<td>Tên điện thoại: </td>

<td><input type = 'text' name = 'tdt' value = <?php echo $_REQUEST['rtdt'];?>></td>

<td><input type = 'submit' name = 'them' value = " Thêm mới "></td>

<td><input type = 'submit' name = 'sua' value = " Sửa "></td>

Trang 20

$username = "root"; // Khai báo username

$password = "133456"; // Khai báo password

$server = "127.0.0.1:3307"; // Khai báo server

$dbname = "QLDT"; // Khai báo database

$connect = new mysqli($server, $username, $password, $dbname);

$sql = "SELECT * FROM DIENTHOAI";

echo "<table border='1' width='70%'>";

echo "<thead>";

echo "<tr>";

echo "<td width='10%'>STT</td>";

echo "<td width='20%'>Mã điện thoại</td>";

echo "<td width='30%'>Tên điện thoại</td>";

echo "<td width='20%'>Giá</td>";

echo "<td width='50%'>Hãng</td>";

echo "<td width='10%'>Sửa</td>";

echo "</tr>";

Trang 23

<input type="submit" name="delete" value="Xóa" />

mysqli_query($connect, $sqlInsert) or die("Ôi không thêm được rồi thầy ạ! Em nghĩ là cơ sở dữ liệu

em khai báo khác thầy rồi ạ :( ");

Trang 24

<?php

$connect = new mysqli("127.0.0.1:3307", "root", "", "ql_sach");

$sql = "SELECT * FROM sach";

echo "<table border='1'>";

echo "<thead>";

echo "<tr>";

echo "<td><center><b>STT</b></center></td>";

echo "<td><center><b>Mã sách</b></center></td>";

echo "<td><center><b>Tên sách</b></center></td>";

echo "<td><center><b>Tác giả</b></center></td>";

Trang 25

<title> Bài thực hành nhóm 9</title>

<link rel="stylesheet" href="style.css">

Trang 26

$update_Query = "UPDATE HANG SET

Ten_hang='{$_POST['ten']}',Don_gia='{$_POST['don_gia']}',Loai='{$_POST['loai']}', WHERE Ma_hang

<label for="">Mã hàng</label>

<input type="text" class="form-control" id="" placeholder="Mã sản phẩm" name="ma">

Trang 27

</div>

<div class="form-group">

<label for="">Tên hàng</label>

<input type="text" class="form-control" id="" placeholder="Nhập vào tên sản phẩm" name="ten">

</div>

<div class="form-group">

<label for="">Đơn Giá</label>

<input type="number" class="form-control" id="" placeholder="Nhập vào số lượng" name="don_gia">

Trang 29

header("location:nhom10.php");

}

if(isset($_POST['xoa'])){

$delete_Query = "DELETE FROM sach WHERE masach = '{$_POST['masach']}'";

$delete_Result = mysqli_query($connect, $delete_Query);

Trang 30

if(isset($_POST['update'])){

$update_Query = "UPDATE sach SET

tensach='{$_POST['tensach']}',tacgia='{$_POST['tacgia']}',nxb='{$_POST['nhaxuatban']}',gia='{$_POST['gia']}',theloai='{$_POST['theloai']}' WHERE masach = '{$_POST['masach']}'";

$update_Result = mysqli_query($connect, $update_Query);

Trang 31

<td><input type="text" name="gia" value="<?php echo $gia; ?>"></td>

<input type="submit" name="them" value="Thêm">

<input type="submit" name="sua" value="Sửa">

<input type="submit" name="xoa" value="Xóa">

Ngày đăng: 24/04/2020, 21:19

TỪ KHÓA LIÊN QUAN

w