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Ả: