Skip to main content

Posts

Showing posts from December 14, 2021

chitiet.php

  <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <?php if(isset($_GET['idbh'])) { $idbh=$_GET['idbh']; include("connect.php"); $sl="select TenBH, LoiBH from webnhac_baihat where idBH=$idbh"; $kq=mysqli_query($link,$sl); $d=mysqli_fetch_array($kq); ?> <h1 align="center"><?php echo $d['TenBH'];?></h1> <div><?php echo $d['LoiBH'];?></div> <?php }?> </body> </html>

casi.php - PHP#8MySQL#4 - Lấy các bài hát theo idCS

  <!doctype html> <html> <head> <meta charset="utf-8"> <title>Ca si</title> </head> <body> <?php include("connect.php"); $sl="select * from webnhac_casi"; $kq=mysqli_query($link,$sl); ?> <ul> <?php while($d=mysqli_fetch_array($kq)) { //Lấy các bài hát theo idCS: $slbh="select idBH, TenBH from webnhac_baihat where idCS=".$d['idCS']; $kqbh=mysqli_query($link,$slbh); if(mysqli_num_rows($kqbh)>0){ ?> <li><?php echo $d['HoTenCS'];?> <ul> <?php while($dbh=mysqli_fetch_array($kqbh)){ ?> <li><a href="chitietbh.php?idbh=<?php echo $dbh['idBH'];?>"><?php echo $dbh['TenBH'];?></a></li> <?php }?> </ul> </li> <?php } }?> </ul> </body> </html> //connect.php   <?php //Kết nối đến server DB: ...

connect.php

  <?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!"); mysqli_query($link,"set names 'utf8'"); ?>

index.php - Kết nối đến server DB

  <!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!"); //$link=mysqli_connect("localhost","root","","webtintuc") or die("Không thể kết nối đến Server!"); //Lấy dữ liệu từ bảng user: idUser, Hoten, Username, Email: $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/>"; /*for($i=1;$i<=$tong;$i++) { //Lấy 1 dòng dữ liệu từ $kq: $d=mysqli_fetch_array($kq); echo $d['HoTen']." có usern...

lienket.php - chèn thuộc tính Url vào Ten từ database & in lên Bảng

  <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <?php include("connect.php"); $sl="select Ten, Url from lienket order by ThuTu ASC"; $kq=mysqli_query($link,$sl); ?> <table width="100" border="1" cellspacing="0" cellpadding="0"> <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> //connect.php   <?php //Kết nối đến server DB: $link=@mysqli_connect("localhost","root","") or die("Không thể kết nối đ...

select.php - PHP#8MySQL#4 - onChange="location.href=this.value"

  <!doctype html> <html> <head> <meta charset="utf-8"> <title>Select - php</title> </head> <body> <?php include("connect.php"); $sl="select Ten, Url from lienket order by ThuTu ASC"; $kq=mysqli_query($link,$sl); ?> <form id="form1" name="form1" method="post"> <select name="lienket" id="lienket" onChange="location.href=this.value"> <option>---Chọn liên kết---</option> <?php while($d=mysqli_fetch_array($kq)) { ?> <option value="<?php echo $d['Url'];?>"><?php echo $d['Ten'];?></option> <?php }?> </select> </form> </body> </html> //connect.php   <?php //Kết nối đến server DB: $link=@mysqli_connect("localhost","root","") or die("Không thể kết nối đến Server!"); //C...

users.php - in dữ liệu từ Database lên Bảng

  <!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!"); $sl="select idUser, HoTen, Username, Email from user"; $kq=mysqli_query($link,$sl); ?> <table width="500" border="1" cellspacing="0" cellpadding="0"> <tbody> <tr> <th width="64" scope="col">idUser</th> <th width="159" scope="col">Họ tên</th> <th width="135" scope="col">Username</th> <th width="132" scope="col">Email</th>...

echo $d['HoTenCS'];

 <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <?php include("connect.php"); $sl="select * from webnhac_casi"; $kq=mysqli_query($link,$sl); ?> <ul> <?php while($d=mysqli_fetch_array($kq)) {     ?> <li><?php echo $d['HoTenCS']; ?></li>     <?php } ?> </ul> </body> </html> //connect.php <?php $link=@mysqli_connect("localhost","root","") or die("Không tìm thấy Sever"); mysqli_select_db($link,"webtintuc") or die("Không tìm thấy DB"); ?>

Chọn liên kết

 <!doctype html> <html> <head> <meta charset="utf-8"> <title>Select php</title> </head> <body> <?php $link=@mysqli_connect("localhost","root","") or die("Không thể kết nối đến Server!"); mysqli_select_db($link,"webtintuc") or die("Không tồn tại DB này!"); mysqli_query($link,"set names 'utf8'"); $sl="select Ten, Url from lienket order by ThuTu ASC"; $kq=mysqli_query($link,$sl); ?> <form id="form1" name="form1" method="post">      <select name="lienket" id="lienket" onChange="location.href=this.value">   <option>---Chọn liên kết---</option>    <?php   while($d=mysqli_fetch_array($kq))   {   ?>     <option value="<?php echo $d['Url'];?>"><?php echo $d['Ten'];?></option>     <?php...

Bài 4 - IS IT SERIOUS? - Có nặng lắm không?

Tự Học NGHE NÓI Tiếng Anh Cấp Tốc · Bài 4 - IS IT SERIOUS? - Có nặng lắm không?

Bài tập 2 - in dữ liệu, sắp xếp, chèn liên kết 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("Không tìm thấy Sever"); mysqli_select_db($link,"webtintuc") or die("Không tìm thấy DB"); $sl="select Ten, Url, ThuTu from lienket order by ThuTu ASC"; $kq=mysqli_query($link,$sl); ?> <table width="300" border="1">   <tbody>     <tr>       <th scope="col">Các liên kết khác</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> KẾT QUẢ:

Bài tập 1 - in dữ liệu 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("Không tìm thấy Sever"); mysqli_select_db($link, "webtintuc") or die("Không tìm thấy DB"); $sl="select idUser, HoTen, Username, Email from user"; $kq=mysqli_query($link,$sl); ?> <table width="600" border="1">   <tbody>     <tr>       <th scope="col">idUser</th>       <th scope="col">HoTen</th>       <th scope="col">Username</th>       <th scope="col">Email</th>     </tr>     <?php     while($d=mysqli_fetch_array($kq)) { ?>     <tr>       <td><?php echo $d['idUser'] ?></td>       <td><?php echo $d['HoTen...