Posts

PHP#13MySQL#9 - GlossyAccordionMenu

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml2/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <script type="text/javascript" src="jquery-1.2.2.pack.js"></script> <script type="text/javascript" src="ddaccordion.js"> /*********************************************** * Accordion Content script- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com) * Visit http://www.dynamicDrive.com for hundreds of DHTML scripts * This notice must stay intact for legal use ***********************************************/ </script> <script type="text/javascript"> ddaccordion.init({ headerclass: "submenuheader", //Shared CSS class name of headers group contentclass: "submenu", //Shared CSS class name of contents group revealtype: "click", //Revea...

PHP#13MySQL#9 - smoothmenu

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <link rel="stylesheet" type="text/css" href="mrk_smooth/ddsmoothmenu.css" /> <link rel="stylesheet" type="text/css" href="mrk_smooth/ddsmoothmenu-v.css" /> <script type="text/javascript" src="mrk_smooth/jquery.min.js"></script> <script type="text/javascript" src=...

PHP#13MySQL#9 - sdmenu

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Slashdot's Menu</title> <link rel="stylesheet" type="text/css" href="sdmenu.css" /> <script type="text/javascript" src="sdmenu.js"> /*********************************************** * Slashdot Menu script- By DimX * Submitted to Dynamic Drive DHTML code library: http://www.dynamicdrive.com * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code ***********************************************/ </script> <script type="text/javascript"> // <![CDATA[ var myMenu; window.onload = function() { myMenu = new SDMenu("my_menu"); myMenu...

Sản phẩm mới, Sản phẩm xem nhiều, Tất cả sản phẩm, Phân trang-Phân nhóm

Image
<!doctype html> <html> <head> <meta charset="utf-8"> <title>Mới Nhất, Xem Nhiều</title> <style> #ds_sp{ width:620px; margin:auto;} .sanpham{ width:120px; float:left; border:1px #2802E9 solid; margin-right:2px; margin-bottom:2px;} .tieude{ font-size:20px; font-weight:bold; background-color: #230DE0; color:#F5EFEF; margin-top:10px; margin-bottom:10px;} .ht{ font-size:20px; color:#E0070B; font-weight:bold;} </style> </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ồn tại DB"); mysqli_query($link,"set names 'utf8'"); $sp=5*4; $sn=5; $sl="select TenSP, UrlHinh, Gia from webtm_sanpham"; $kq=mysqli_query($link,$sl); $tsp=mysqli_num_rows($kq); $tst=ceil($tsp/$sp); $tsn=ceil($tst/$sn); if(isset($_GET['p'])){$p=$_G...

Sản phẩm mới, Sản phẩm xem nhiều

Image
<!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> <style> #ds_sp{width: 620px; margin: auto;} .sanpham{width: 120px; float: left; height: 250px; border: 1px #4D3BE5 solid; margin-right: 2px; margin-bottom: 2px;} .ht{font-size: 20px; color: #F10C0F; font-weight: bold;} .tieude{ background-color:#0A16F0; font-size:20px; font-weight:bold; margin-bottom:10px; margin-top:10px; width:100%; color:#F5F3F3;} </style> </head> <body> <div id="ds_sp"> <div class="tieude">Sản Phẩm Mới</div> <?php include("connect.php"); //Quy ước 1 trang gồm 20sp: $sp=5*2; //Truy vấn lấy tất cả sản phẩm: $sl="select TenSP, UrlHinh, Gia from webtm_sanpham"; $kq=mysqli_query($link,$sl); //tính tổng sản phẩm: $tsp=mysqli_num_rows($kq); //Tính tổng số trang: $tst=ceil($tsp/$sp); //Tính trang hiện tại: if(isset($_GET[...

PHP#12MySQL#8 - Phân Trang - Phân Nhóm (RẤT QUAN TRỌNG) n=ceil(p/sn) //p=(n-1)sn+1 //Lần đầu chạy lên p=n=1 //$dau=($n-1)*$sn+1; $cuoi=$n*$sn

Image
<!doctype html> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> <style> .ht{font-size: 20px; color: #F10C0F; font-weight: bold;} </style> </head> <body> <?php include("connect.php"); //Quy ước 1 trang gồm 5sp: $sp=5; //Quy ước 1 nhóm gồm 5 trang: $sn=5; //Truy vấn lấy tất cả sản phẩm: $sl="select TenSP, UrlHinh, Gia from webtm_sanpham"; $kq=mysqli_query($link,$sl); //tính tổng sản phẩm: $tsp=mysqli_num_rows($kq); //Tính tổng số trang: $tst=ceil($tsp/$sp); //Tính tổng số nhóm: $tsn=ceil($tst/$sn); //Tính nhóm, trang hiện tại: if(isset($_GET['p'])) {$p=$_GET['p']; $n=ceil($p/$sn);} else if(isset($_GET['n'])){$n=$_GET['n'];$p=($n-1)*$sn+1;} else $p=$n=1; //Tính vị trí cần để lấy sản phẩm: $vt=($p-1)*$sp; $slsp="select TenSP, UrlHinh, Gia from webtm_sanpham limit $vt,$sp"; $kqsp...

PHP#12MySQL#8 - Phân Trang - Phân Cột

Image
<!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> <style> #ds_sp{width: 650px; margin: auto;} .sanpham{width: 120px; float: left; height: 250px; border: 1px #4D3BE5 solid; margin-right: 2px; margin-bottom: 2px;} .ht{font-size: 20px; color: #F10C0F; font-weight: bold;} </style> </head> <body> <div id="ds_sp"> <?php include("connect.php"); //Quy ước 1 trang gồm 20sp: $sp=5*4; //Truy vấn lấy tất cả sản phẩm: $sl="select TenSP, UrlHinh, Gia from webtm_sanpham"; $kq=mysqli_query($link,$sl); //tính tổng sản phẩm: $tsp=mysqli_num_rows($kq); //Tính tổng số trang: $tst=ceil($tsp/$sp); //Tính trang hiện tại: if(isset($_GET['p'])) $p=$_GET['p']; else $p=1; //Tính vị trí cần để lấy sản phẩm: $vt=($p-1)*$sp; $slsp="select TenSP, UrlHinh, Gia from webtm_sanpham limit $vt,$sp"; $kqsp=mysqli_query(...

Kết hợp LỌC + PHÂN TRANG chungloaisp, loaisp, sanpham

Image
<!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> <style> .ht{ font-size:20px; color:#F40408; font-weight:bold;} </style> </head> <body> <form method="get" id="form1" name="form1"> <p> <label>Chủng loại sp: </label> <select name="chungloai" id="chungloai" onChange="form1.submit();"> <?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ồn tại DB"); mysqli_query($link,"set names 'utf8'"); $sl="select * from webtm_chungloaisp"; $kq=mysqli_query($link,$sl); $idCL=0; if(isset($_GET['chungloai'])) $idCL=$_GET['chungloai']; while($d=mysqli_fetch_array($kq)) { if($idCL==0) $idCL=$d['idCL']; ?...

(Phân trang) Liên kết trang $_GET, hiện dữ liệu và phân trang tại trang khác WHERE , LIMIT

Image
Database : https://drive.google.com/file/d/16mUt4iNR-FOraT1NAjtpXkPJVh3tPaiY/view Hình ảnh : https://drive.google.com/file/d/19hJroj8BNEVV4_osAo2eXHspMciJb6LA/view //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'"); ?> // loaisp_duc.php <!doctype html> <html> <head> <meta charset="utf-8"> <title>loaisp_duc</title> </head> <body> <?php include("connect.php"); $sl="select * from webtm_loaisp"; $kq=mysqli_query($link,$sl); while($d=mysqli_fetch_array($kq)) { echo "<p><a href='pt_loai_duc.php? idLoai={$d['idLoai']} '>{$d['TenLoai']}</a></p>...

(Phân trang) cần đếm Tổngsốsảnphẩm, Tổngsốtrang, truyền tham số Trang, tính Vịtrí (dựa vào tham số Trang) $vt=($p-1)*$sp

Image
Database : https://drive.google.com/file/d/16mUt4iNR-FOraT1NAjtpXkPJVh3tPaiY/view Hình ảnh : https://drive.google.com/file/d/19hJroj8BNEVV4_osAo2eXHspMciJb6LA/view //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'"); ?> //phantrang_duc.php?p="sốtrang" <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> <style> .ht{font-size: 20px; color: #F10C0F; font-weight: bold;} </style> </head> <body> <?php include("connect.php"); $sp=5; echo "Sản phẩm mỗi trang: ".$sp; $sl="select TenSP, UrlHinh, Gia from webtm_sanpham"; $kq=mysqli_query($...

PHP#11MySQL#7 - Phân Trang (rất quan trọng)

Image
Database : https://drive.google.com/file/d/16mUt4iNR-FOraT1NAjtpXkPJVh3tPaiY/view Hình ảnh : https://drive.google.com/file/d/19hJroj8BNEVV4_osAo2eXHspMciJb6LA/view  //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'"); ?> //phantrang.php : Bài tập 1 <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> <style> .ht{font-size: 20px; color: #F10C0F; font-weight: bold;} </style> </head> <body> <?php include("connect.php"); //Quy ước 1 trang gồm 5sp: $sp=5; //Truy vấn lấy tất cả sản phẩm: $sl="select TenSP, UrlHinh, Gia from webtm_sanpham"; $kq=mysqli_query(...

Cách 2: LỌC SẢN PHẨM: Chủng Loại --->Loại-->Sản Phẩm

Image
Database : https://drive.google.com/file/d/16mUt4iNR-FOraT1NAjtpXkPJVh3tPaiY/view Hình ảnh : https://drive.google.com/file/d/19hJroj8BNEVV4_osAo2eXHspMciJb6LA/view <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <form method="get" id="form1" name="form1"> <p> <label for="loaisp">Chủng loại sp:</label> <select name="chungloai" id="chungloai" onChange="form1.submit();"> <?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ồn tại DB"); mysqli_query($link,"set names 'utf8'"); $sl="select * from webtm_chungloaisp"; $kq=mysqli_query($link,$sl); $idCL=0; while($d=mysqli_fetch_array($kq)) ...

LỌC SẢN PHẨM: Chủng Loại --->Loại-->Sản Phẩm (b1, b2, b3, b4, b5, b6) gồm 6 bước PHP&MySQL

Image
Database : https://drive.google.com/file/d/16mUt4iNR-FOraT1NAjtpXkPJVh3tPaiY/view Hình ảnh : https://drive.google.com/file/d/19hJroj8BNEVV4_osAo2eXHspMciJb6LA/view Mục Tiêu: //connetc.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'");  ?>  

b6.php - PHP#10MySQL#6 (b4.php, b5.php, b6.php) - Xong phần lọc sản phẩm

  <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <form id="form1" name="form1" method="get"> <p> <label for="chungloai">Chủng loai sp:</label> <select name="chungloai" id="chungloai" onChange="form1.submit();"> <?php include("connect.php"); $sl="select * from webtm_chungloaisp"; $kq=mysqli_query($link,$sl); $idCL=0; if(isset($_GET['chungloai'])) $idCL=$_GET['chungloai']; //Gán lại giá trị cho $idCL khi người dùng chọn chủng loại khác (submit form) while($d=mysqli_fetch_array($kq)) { if($idCL==0)$idCL=$d['idCL']; //giữ lại idCL của option đầu tiên ?> <option value="<?php echo $d['idCL'];?>" <?php if($idCL==$d['idCL']) echo "selected";?>>...

b5.php - PHP#10MySQL#6 (b4.php, b5.php, b6.php)

<!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <form id="form1" name="form1" method="get"> <p> <label for="chungloai">Chủng loai sp:</label> <select name="chungloai" id="chungloai" onChange="form1.submit();"> <?php include("connect.php"); $sl="select * from webtm_chungloaisp"; $kq=mysqli_query($link,$sl); $idCL=0; if(isset($_GET['chungloai'])) $idCL=$_GET['chungloai']; //Gán lại giá trị cho $idCL khi người dùng chọn chủng loại khác (submit form) while($d=mysqli_fetch_array($kq)) { if($idCL==0)$idCL=$d['idCL']; //giữ lại idCL của option đầu tiên ?> <option value="<?php echo $d['idCL'];?>" <?php if($idCL==$d['idCL']) echo "selected";?>><?...

b4.php - PHP#10MySQL#6 (b4.php, b5.php, b6.php)

  <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <form id="form1" name="form1" method="get"> <p> <label for="chungloai">Chủng loai sp:</label> <select name="chungloai" id="chungloai" onChange="form1.submit();"> <?php include("connect.php"); $sl="select * from webtm_chungloaisp"; $kq=mysqli_query($link,$sl); $idCL=0; while($d=mysqli_fetch_array($kq)) { if($idCL==0)$idCL=$d['idCL']; //giữ lại idCL của option đầu tiên ?> <option value="<?php echo $d['idCL'];?>" <?php if(isset($_GET['chungloai'])&&$_GET['chungloai']==$d['idCL']) echo "selected";?>><?php echo $d['TenCL'];?></option> <?php }?> </selec...

PHP#10MySQL#6 (b4.php, b5.php, b6.php) Lọc sản phẩm CHỦNG LOẠI-->Loại-->sản phẩm // Đã XONG

Image
Mục tiêu: //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'"); ?>

b3.php - PHP#9MySQL#5 - if($idCL==0) $idCL=$d['idCL']; //giữ lại idCL của option đầu tiên

Image
//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'");  ?>  

b2.php - PHP#9MySQL#5 - Submit bằng lệnh JavaScrip: onChange="form1.submit();" thay thế nút Submit - Dùng Selected khi chọn đối tượng

Image
//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'"); ?>

b1.php - PHP#9MySQL#5 - Lọc sản phẩm

Image
//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'"); ?>

theloaibh.php, dsbh.php - PHP#9MySQL#5 - bắt đối tượng khi click, liên kết qua trang khác để hiện thị nội dung tương ứng $_GET[' '] trong PHP

Image
 //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'"); ?>

PHP#9MySQL#5 - locSP( b1.php, b2.php, b3.php) - Lọc sản phẩm

Image
//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'"); ?>

in HoTenCS từ database ra màn hình - Tiếp theo in thêm TenBH dưới HoTenCS - Tiếp theo chỉ hiện những ca sĩ có bài hát. CUỐI CÙNG in ra lời bài hát từ liên kết đến trang chitietbh.php

Image
  <!doctype html> <html> <head> <meta charset="utf-8"> <title>Ca si Duc 4</title> </head> <body> <?php include("connect_duc.php"); $sl="select * from webnhac_casi"; $kq=mysqli_query($link,$sl); ?> <ul> <?php while($d=mysqli_fetch_array($kq)) { $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="chitiet_duc.php?idbh=<?php echo $dbh['idBH']; ?>"><?php echo $dbh['TenBH']; ?></a></li> <?php } ?> </ul> </li> <?php } } ?> </ul> </body> </html>

in HoTenCS từ database ra màn hình - Tiếp theo in thêm TenBH dưới HoTenCS - Tiếp theo chỉ hiện những ca sĩ có bài hát

Image
  <!doctype html> <html> <head> <meta charset="utf-8"> <title>Ca sĩ Duc</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"); mysqli_query($link, "set names 'utf8'"); $sl="select * from webnhac_casi"; $kq=mysqli_query($link,$sl); ?> <ul> <?php while($d=mysqli_fetch_array($kq)) { $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><?php echo $dbh['TenBH']; ?></li> ...

in HoTenCS từ database ra màn hình - Tiếp theo in thêm TenBH dưới HoTenCS

Image
<!doctype html> <html> <head> <meta charset="utf-8"> <title>Ca sĩ Duc</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"); mysqli_query($link, "set names 'utf8'"); $sl="select * from webnhac_casi"; $kq=mysqli_query($link,$sl); ?> <ul> <?php while($d=mysqli_fetch_array($kq)) { ?> <li><?php echo $d['HoTenCS']; $slbh="select idBH, TenBH from webnhac_baihat where idCS=".$d['idCS']; $kqbh=mysqli_query($link,$slbh); ?> <ul> <?php while($dbh=mysqli_fetch_array($kqbh)){ ?> <li><?php echo $dbh['TenBH']; ?></li> <?php } ?> ...

in HoTenCS từ database ra màn hình

Image
<!doctype html> <html> <head> <meta charset="utf-8"> <title>Ca sĩ Duc</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"); mysqli_query($link, "set names 'utf8'"); $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>

Database webtintuc.sql

  -- phpMyAdmin SQL Dump -- version 2.10.2 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Nov 11, 2008 at 12:03 AM -- Server version: 5.0.18 -- PHP Version: 5.2.3 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- Database: `ajax` -- -- -------------------------------------------------------- -- -- Table structure for table `bandocykien` -- CREATE TABLE `bandocykien` ( `idYKien` int(11) NOT NULL auto_increment, `idTin` int(11) NOT NULL default '0', `Ngay` date NOT NULL default '0000-00-00', `NoiDung` text NOT NULL, `Email` varchar(255) default NULL, `HoTen` varchar(255) default NULL, `DiaChi` varchar(255) default NULL, PRIMARY KEY (`idYKien`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- -- Dumping data for table `bandocykien` -- -- -------------------------------------------------------- -- -- Table structure for table `binhchon` -- CREATE TABLE `binhchon` ( `idBC` int(11) NOT NULL auto_incre...