Tra Từ Điển

Thời gianTiếtThứ 2Thứ 3Thứ 4Thứ 5Thứ 6
8g40 - 9g101Tiếng Việt
Tiếng Anh
Tiếng Việt
Tiếng Việt
9g10 - 9g302Nghỉ giải lao
Tiếng Anh
Nghỉ giải lao
Nghỉ giải lao
9g30 - 10g3Toán
Toán
Toán

Monday, December 13, 2021

Kết nối đến Server Database - Chọn database cần thao tác - Lấy dữ liệu từ bảng - Thực hiện query - Lấy 1 dòng dữ liệu




<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<?php
//Kết nối đến server DB:
$link=@mysqli_connect("localhost","root","") or die("Không thể kết nối đến Server");

        //Chọn database cần thao tác:
mysqli_select_db($link, "webtintuc") or die("Không tồn tại DB này!");

        //Lấy dữ liệu từ bảng user:
$sl="select idUser, HoTen, Username, Email from user";

        //Thực hiện query:
$kq=mysqli_query($link,$sl);
$tong=mysqli_num_rows($kq);
echo "Số dòng dữ liệu lấy được: $tong<br/>";

//Lấy 1 dòng dữ liệu từ $kq: $d=mysqli_fetch_array($kq) while($d=mysqli_fetch_array($kq)) { echo $d['HoTen']." Có username là: ".$d['Username']."<br/>"; }       
?>
</body>
</html>

KẾT QUẢ: 

0 comments:

Post a Comment