Skip to main content

Posts

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

Bài 3 - IF YOU INSIST - Nếu anh quyết thế

Tự Học NGHE NÓI Tiếng Anh Cấp Tốc · Bài 3 - IF YOU INSIST - Nếu Anh Quyết Thế

Bài 2 - SOME OTHER TIME - Vào dịp khác

Bài 1 - SO DO I - Tôi cũng thế

Tự Học NGHE NÓI Tiếng Anh Cấp Tốc - American Accent Training - TheWindy, Chủ biên: Jenny Nguyễn - MCBook - Nhà xuất bản Hồng Đức

Duc · Tự Học NGHE NÓI Tiếng Anh Cấp Tốc - American Accent Training - TheWindy Tự Học NGHE NÓI Tiếng Anh Cấp Tốc - American Accent Training - TheWindy, Chủ biên: Jenny Nguyễn - MCBook - Nhà xuất bản Hồng Đức

PHP#7 - MySQL#3 - Hiện thông tin Tên, gắn liên kết, sắp xếp ThuTu tăng dần ( $sl="select Ten, Url, ThuTu from lienket order by ThuTu ASC"; ) LÊN BẢNG

<!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <?php $link=@mysqli_connect("localhost","root","") or die; mysqli_select_db($link,"webtintuc") or die; $sl="select Ten, Url, ThuTu from lienket order by ThuTu ASC"; $kq=mysqli_query($link,$sl); $d=mysqli_fetch_array($kq) ?> <table width="200" border="1"> <tbody> <tr> <th scope="col">Các liên kết</th> </tr> <?php while($d=mysqli_fetch_array($kq)) { ?> <tr> <td><a href="<?php echo $d['Url']; ?>"><?php echo $d['Ten']; ?></a></td> </tr> <?php } ?> </tbody> </table> </body> </html>

PHP#7 - MySQL#3 - Hiện thông tin ( $sl="select idUser, HoTen, Username, Email from user"; ) LÊN BẢNG

<!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <?php $link=@mysqli_connect("localhost","root","") or die; mysqli_select_db($link,"webtintuc") or die; $sl="select idUser, HoTen, Username, Email from user"; $kq=mysqli_query($link,$sl); ?> <table width="500" border="1"> <tbody> <tr> <th width="64" scope="col">idUser</th> <th width="159" scope="col">HoTen</th> <th width="135" scope="col">Username</th> <th width="132" scope="col">Email</th> </tr> <?php while($d=mysqli_fetch_array($kq)) { ?> <tr> <td><?php echo $d['idUser'];?></td> <td><?php echo $d['HoTen...