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

Tuesday, March 8, 2022

PHP#33MySQL#29 - Đếm lượt truy cập (KẾT THÚC KHÓA HỌC)

//hitcounter.php
<?php
session_start(); 
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
<?php 
include("../connect.php");
//cập nhật số luowhtj truy cập:
$sl="update counter set cnt=cnt+1";
mysqli_query($link,$sl);
//Lấy dữ liệu số lượt truy cập để hiển thị ra web:
$sl2="select * from counter";
$kq=mysqli_query($link,$sl2);
$d=mysqli_fetch_array($kq);

//Định dạng:
$chuoi=str_pad($d['cnt'],6,"0",STR_PAD_LEFT);
$luottrycap="";
for($i=0;$i<strlen($chuoi);$i++)
{
$tam=substr($chuoi,$i,1);
$luottrycap.="<img src='images/$tam.png'/>";
}

/*-Khi user truy cập vào website:
+lần đầu tuy cập: Lưu thông tin của user lên csdl
+Sau lần đầu tiên: cập nhtaaj lastvisit
- Xóa các dòng dữ liệu quá 1 phút (Quy ước thời gian để khẳng định online hay offline: 1 phút)
- Thống kê số liệu người dùng online, thành viên online, khác online*/
$id=session_id();
$timeout=60; //1 phút
if(isset($_SESSION['iduser']))
$user=$_SESSION['iduser'];
else $user="";
//$lastvisited=time(); //unix_timestamp()
//Kiểm tra user có trên csdl chưa:
$sl1="select * from user_online where id='$id'";
$kq1=mysqli_query($link,$sl1);
if(mysqli_num_rows($kq1))
{
//Đã có trong csdl thì cập nhật lại tông tin:
$sl2="select * from user_online set lastvisit=unix_timestamp(), user='$user' where id='$id'";
mysqli_query($link,$sl2);
}
else{
//Chưa có trong csdl thêm mới:
$sl2="insert into user_online values('$id',unix_timestamp(),'$user')";
mysqli_query($link,$sl2);
}

//Xóa những dòng đã quá thời gian quy ước:
$sl3="delete from user_online where unix_timestamp()-lastvisit > $timeout";
mysqli_query($link,$sl3);

//Thống kê tổng số người online:
$sl4="select count(*) as tongso from user_online";
$kq4=mysqli_query($link,$sl4);
$d4=mysqli_fetch_array($kq4);
//Định dạng:
$chuoi=str_pad($d4['tongso'],3,"0",STR_PAD_LEFT);
$tongso="";
for($i=0;$i<strlen($chuoi);$i++)
{
$tam=substr($chuoi,$i,1);
$tongso.="<img src='images/$tam.png'/>";
}

//Thống kê số thành viên online:
$sl5="select count(*) as souser from user_online where user!=''";
$kq5=mysqli_query($link,$sl5);
$d5=mysqli_fetch_array($kq5);
?>
<div>Lượt truy cập: <?php echo $luottrycap;?></div>
<div>Tổng sô người online: <?php echo $tongso;?></div>
<div>Sô thành viên online: <?php echo $d5['souser'];?></div>
</body>
</html>

//test_user.php
<?php 
session_start();
$_SESSION['iduser']=1;
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
</body>
</html>

Saturday, March 5, 2022

PHP#32MySQL#28 - Ajax3 + EMAIL

//connect.php

<?php
$link=@mysqli_connect("localhost","root","") or die("Khong the ket noi den server");
mysqli_select_db($link,"webtintuc") or die ("Kiem tra lai ten database!");
mysqli_query($link,"set names 'utf8'");
?>

//dangky.php

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="xuly_dangky.php">
  <p>
    <label for="hoten">Họ tên:</label>
    <input type="text" name="hoten" id="hoten">
  </p>
  <p>
    <label for="diachi">Dia chi:</label>
    <input type="text" name="diachi" id="diachi">
  </p>
  <p>
    <label for="username">Username:</label>
    <input type="text" name="username" id="username">
  </p>
  <p>
    <label for="pass">Password:</label>
    <input type="text" name="pass" id="pass">
  </p>
  <p>
    <label for="email">Email:</label>
    <input type="text" name="email" id="email">
  </p>
  <p>
    <input type="submit" name="dangky" id="dangky" value="Đăng ký">
  </p>
</form>
</body>
</html>

Thursday, March 3, 2022

PHP#31MySQL#27 - Ajax2

//checkuser.php

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script type="text/javascript" src="jquery-3.6.0.js"></script>
</head>

<body>
<script type="text/javascript"> 
$(document).ready(function(){
$("#username").blur(function(){
$.ajax({
                    type:"POST",
                    url:"xuly_checkuser.php",
                    data:"user="+$("#username").val(),
                    success:function(abc)
{
                        if(abc=="1")
$("#kq").html("User này đã tồn tại. Mời bạn chọn user khác!");
else
{
$("#kq").html("User này chưa có. Bạn có thể sử dụng");
$("#dangky").removeAttr("disabled");
}
                    }
})
})
//Viết code cho sự kiện focus lên username:
$("#username").focus(function(){
$("#dangky").attr("disabled",true);
$("#kq").html("");
})
    });
</script>

<form method="get" id="form1" name="form1" action="">
  <p>
    <label for="textfield">Họ Tên:</label>
    <input type="text" name="hoten" id="hoten">
  </p>
  <p>
    <label for="username">Username:</label>
    <input type="text" name="username" id="username"><br/>
    <div id="kq"></div>
  </p>
  <p>
    <label for="password">Password:</label>
    <input type="password" name="password" id="password">
  </p>
  <p>
    <label for="confirmpassword">Re Password:</label>
    <input type="password" name="confirmpassword" id="confirmpassword">
  </p>
  <p>
    <input type="submit" name="dangky" id="dangky" value="Đăng ký" disabled>
  </p>
</form>
</body>
</html>

//xuly_checkuser.php

<?php 
if(isset($_POST['user']))
{
include("connect.php");
$user=$_POST['user'];
$sl="select * from webtm_user where Username='$user'";
$kq=mysqli_query($link,$sl);
if(mysqli_num_rows($kq))
echo "1";
else
echo "0";
}
?>

PHP#30MySQL#26 - Ajax

Thursday, February 24, 2022

PHP#29MySQL#25 - Captcha & Bình chọn

//CAPTCHA: vidu.php

<?php
session_start();
//phát sinh 6 ký tự ngẫu nhiên:
$dodai=6;
$chuoi="QWERTYUIOPASDFGHJKLZXCVBNM0123456789";
$capt="";
for($i=1;$i<=$dodai;$i++)
{
$vitri=rand(0,35);
$capt.=substr($chuoi,$vitri,1);
}
$_SESSION['captcha']=$capt;
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
<form action="xuly.php" name="form1"id="form1" method="post">
  <p>
    <label for="textfield">Ho Ten:</label>
    <input type="text" name="textfield" id="textfield">
  </p>
  <p>
    <label for="textfield2">Mat Khau:</label>
    <input type="text" name="textfield2" id="textfield2">
  </p>
  <p>
    <label for="textfield3">Nhap ma xac nhan:</label>
    <input type="text" name="maxn" id="maxn"><span><?php echo $capt;?></span>
  </p>
  <p>
    <input type="submit" name="thuchien" id="submit" value="Đăng Nhập">
  </p>
</form>
</body>
</html>

//CAPTCHA: xuly.php
<?php 
session_start();
?>

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
<?php
if(isset($_POST['maxn'])&&$_POST['maxn']==$_SESSION['captcha'])
{
echo "Nhập đúng mã xác nhận!";
}
else
echo "Nhập sai mã";
?>
</body>
</html>


//BÌNH CHỌN: binhchon.php
<!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>Binh chon</title>
</head>

<body>

<form id="form1" name="form1" method="post" action="xuly.php">
  <p><?php 
include("../connect.php");
$sl="select * from binhchon where AnHien=1 limit 0,1";
$kq=mysqli_query($link,$sl);
$d=mysqli_fetch_array($kq);
echo "Cau hoi: ".$d['MoTa']."<br>";
$slpa="select * from phuongan where idBC=".$d['idBC'];
$kqpa=mysqli_query($link,$slpa);
$i=0;
while($dpa=mysqli_fetch_array($kqpa))
{
?>
  
    <label>
      <input type="radio" name="binhchon" value="<?php echo $dpa['idPA'];?>" id="binhchon_<?php echo $dpa['idPA'];?>" <?php if($i==0) echo "checked='checked'";$i++;?> />
      <?php echo $dpa['MoTa'];?></label>
    <br />
 <?php }?>
  </p>
  <p>
    <input type="submit" name="thuchien" id="thuchien" value="Binh chon" />
    <input type="button" name="button" id="button" value="Xem ket qua" onclick="location.href='ketquabinhchon.php'" />
  </p>
</form>
</body>
</html>

//BÌNH CHỌN: xuly.php
<?php  ob_start(); 
if(isset($_POST['binhchon']))
{
include("../connect.php");
$sl="update phuongan set SoLanChon=SoLanChon+1 where idPA=".$_POST['binhchon'];
if(mysqli_query($link,$sl))
header("location:ketquabinhchon.php"); 
else
echo "Binh chon that bai";
}
?>

//BÌNH CHỌN: ketquabinhchon.php
<!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>
</head>

<body>
<table width="600" border="1">
  <tr>
    <td colspan="3">Cau hoi: <?php 
include("../connect.php");
$sl="select * from binhchon where AnHien=1 limit 0,1";
$kq=mysqli_query($link,$sl);
$d=mysqli_fetch_array($kq);
echo $d['MoTa'];

//Tinh tong so lan chon:
$kqtsbc=mysqli_query($link,"select sum(SoLanChon) as tongso from phuongan where idBC=".$d['idBC']);
$dtsbc=mysqli_fetch_array($kqtsbc);

?></td>
  </tr>
 <?php 
 $slpa="select * from phuongan where idBC=".$d['idBC'];
 $kqpa=mysqli_query($link,$slpa);
 while($dpa=mysqli_fetch_array($kqpa))
 { 
 
 ?>
  <tr>
    <td><?php echo $dpa['MoTa'];?></td>
    <td width="210"><table width="200" border="0">
      <tr>
        <td bgcolor="#FF0000" width="<?php echo round($dpa['SoLanChon']*200/$dtsbc['tongso'],0)?>">&nbsp;</td>
        <td> <?php echo round($dpa['SoLanChon']*100/$dtsbc['tongso'],2)?>%</td>
      </tr>
    </table></td>
    <td>So lan:<?php echo $dpa['SoLanChon'];?></td>
  </tr>
  
 <?php }?> 
  <tr>
    <td colspan="3" align="right">Tong so lan chon:<?php echo $dtsbc['tongso'];?></td>
  </tr>
</table>
</body>
</html>

VID DỤ MẪU GOOLE: piechart.php
<?php 
include("../connect.php");
$sl="select * from binhchon where AnHien=1 limit 0,1";
$kq=mysqli_query($link,$sl);
$d=mysqli_fetch_array($kq);


//Lấy các phương án theo câu hỏi bình chọn:
$slpa="select * from phuongan where idBC=".$d['idBC'];
$kqpa=mysqli_query($link,$slpa);
?>
<html>
  <head>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">
      google.charts.load('current', {'packages':['corechart']});
      google.charts.setOnLoadCallback(drawChart);

      function drawChart() {

        var data = google.visualization.arrayToDataTable([
          ['Mô tả', 'Số lần bình chọn']<?php 
  while($dpa=mysqli_fetch_array($kqpa)) {?>,
          ['<?php echo $dpa['MoTa'];?>',    <?php echo $dpa['SoLanChon'];?>]<?php }?>
        ]);

        var options = {
          title: '<?php echo $d['MoTa']?>'
        };

        var chart = new google.visualization.PieChart(document.getElementById('piechart'));

        chart.draw(data, options);
      }
    </script>
  </head>
  <body>
    <div id="piechart" style="width: 900px; height: 500px;"></div>
  </body>
</html>



PHP#28MySQL#24 - GIỎ HÀNG 3 (xong)

 //datbao.php
<?php
session_start();
if(!isset($_SESSION['giohang'])) $_SESSION['giohang']=array();
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>

<form id="f" name="form1" method="post" action="xuly.php">
  <p>Đăng Ký Đặt Báo
  
  <p>
    <label for="loaibao">Loại báo:</label>
    <select name="loaibao" id="loaibao">
    <?php 
include("connect.php");
$sql="select * from loaibao";
$kq=mysqli_query($link,$sql);
while($d=mysqli_fetch_array($kq))
{

?>
      <option value="<?php echo $d['mabao'];?>"><?php echo $d['tenbao'];?></option>
       <?php }?>
    </select>
  </p>
  <p>
    <label for="soluong">Số lượng:</label>
    <input type="text" name="soluong" id="soluong" value="1">
  </p>
  <p>
    <input type="submit" name="themsp" id="themsp" value="Đưa vào giỏ hàng">
  </p>
</form>
<?php 
//Kiểm tra giỏ hàng có sản phẩm không:
if(count($_SESSION['giohang'])>0)
{
?>

<form method="post" id="form2" name="form2" action="xuly.php">
  <table width="800" border="1" cellspacing="0" cellpadding="0">
    <tbody>
      <tr>
        <th colspan="6" scope="col">Danh sách các loại báo cần đặt</th>
      </tr>
      <tr>
        <th width="64">STT</th>
        <th width="124">Tên Báo</th>
        <th width="70">Giá</th>
        <th width="144">Số lượng</th>
        <th width="321">Thành tiền</th>
        <th width="63">Xóa</th>
      </tr>
      <?php 
  $tong=0;
for($i=0;$i<count($_SESSION['giohang']);$i++)
{
$tong=$tong+$_SESSION['giohang'][$i]['soluong']*$_SESSION['giohang'][$i]['gia'];
  ?>
      <tr>
        <td><?php echo $i+1;?></td>
        <td align="center"><?php echo $_SESSION['giohang'][$i]['tenbao'];?></td>
        <td align="center"><?php echo $_SESSION['giohang'][$i]['gia'];?></td>
        <td align="center"><input name="SL<?php echo $i;?>" type="text" id="SL" value="<?php echo $_SESSION['giohang'][$i]['soluong'];?>" size="5"></td>
        <td align="center"><?php echo $_SESSION['giohang'][$i]['soluong']*$_SESSION['giohang'][$i]['gia'];?></td>
        <td align="center"><a href="xuly.php?xoasp=<?php echo $i;?>">xóa</a></td>
      </tr>
      <?php }?>
      <tr>
        <td colspan="6" align="right">Tổng cộng tiền: <?php echo $tong;?> VNĐ</td>
      </tr>
    </tbody>
  </table>
  <p>
    <input type="submit" name="capnhat" id="capnhat" value="Cập Nhật">
    <input type="button" name="datbao" id="datbao" value="Đặt Báo" onClick="location.href='thongtinkhachhang.php'">
</form>
<?php }?>
</body>

</html>

//thongtinkhachhang.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
<form action="xuly.php" method="post" id="form1" name="form1">
  <p>
    <label for="hoten">Họ tên:</label>
    <input type="text" name="hoten" id="hoten">
  </p>
  <p>
    <label for="diachi">Địa chỉ:</label>
    <input name="diachi" type="text" id="diachi">
  </p>
  <p>
    <label for="sodt">Số điện thoại:</label>
    <input type="text" name="sodt" id="sodt">
  </p>
  <p>
    <label for="email">Email:</label>
    <input type="text" name="email" id="email">
  </p>
  <p>
    <input type="submit" name="dathang" id="dathang" value="dathang">
  </p>
</form>
</body>
</html>

Saturday, February 19, 2022

PHP#27MySQL#23 - GIỎ HÀNG 1+2

PHẦN 2:

//datbao.php

<?php
session_start();
if(!isset($_SESSION['giohang'])) $_SESSION['giohang']=array();
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>

<form id="f" name="form1" method="post" action="xuly.php">
  <p>Đăng Ký Đặt Báo
  
  <p>
    <label for="loaibao">Loại báo:</label>
    <select name="loaibao" id="loaibao">
    <?php 
include("connect.php");
$sql="select * from loaibao";
$kq=mysqli_query($link,$sql);
while($d=mysqli_fetch_array($kq))
{

?>
      <option value="<?php echo $d['mabao'];?>"><?php echo $d['tenbao'];?></option>
       <?php }?>
    </select>
  </p>
  <p>
    <label for="soluong">Số lượng:</label>
    <input type="text" name="soluong" id="soluong" value="1">
  </p>
  <p>
    <input type="submit" name="themsp" id="themsp" value="Đưa vào giỏ hàng">
  </p>
</form>
<?php 
//Kiểm tra giỏ hàng có sản phẩm không:
if(count($_SESSION['giohang'])>0)
{
?>

<form method="post" id="form2" name="form2" action="">
  <table width="800" border="1" cellspacing="0" cellpadding="0">
    <tbody>
      <tr>
        <th colspan="6" scope="col">Danh sách các loại báo cần đặt</th>
      </tr>
      <tr>
        <th width="64">STT</th>
        <th width="124">Tên Báo</th>
        <th width="70">Giá</th>
        <th width="144">Số lượng</th>
        <th width="321">Thành tiền</th>
        <th width="63">Xóa</th>
      </tr>
      <?php 
  $tong=0;
for($i=0;$i<count($_SESSION['giohang']);$i++)
{
$tong=$tong+$_SESSION['giohang'][$i]['soluong']*$_SESSION['giohang'][$i]['gia'];
  ?>
      <tr>
        <td><?php echo $i+1;?></td>
        <td><?php echo $_SESSION['giohang'][$i]['tenbao'];?></td>
        <td><?php echo $_SESSION['giohang'][$i]['gia'];?></td>
        <td><input type="text" name="SL" id="SL" value="<?php echo $_SESSION['giohang'][$i]['soluong'];?>"></td>
        <td><?php echo $_SESSION['giohang'][$i]['soluong']*$_SESSION['giohang'][$i]['gia'];?></td>
        <td><a href="#">xóa</a></td>
      </tr>
      <?php }?>
      <tr>
        <td colspan="6">Tổng cộng tiền: <?php echo $tong;?> VNĐ</td>
      </tr>
    </tbody>
  </table>
  <p>
    <input type="button" name="capnhat" id="capnhat" value="Cập nhật">
</form>
<?php }?>
</body>
</html>

//xuly.php

<?php 
session_start();
include("connect.php");
//Thêm sản phẩm vào giỏ hàng(session):
if(isset($_POST['themsp']))
{
//Kiểm tra sản phẩm có trong giỏ hàng chưa
//Nếu chưa có thì tiến hành thêm bình thường
//Ngược lịa thì chỉ cần cạp nhật số lượng
$kt=0; //kt=0 là đánh dấu chưa có sản phẩm trong giỏ hàng
for($i=0;$i<count($_SESSION['giohang']);$i++)
{
if($_POST['loaibao']==$_SESSION['giohang'][$i]['mabao'])
{
$_SESSION['giohang'][$i]['soluong']+=$_POST['soluong'];
$kt=1;
break;
}
}
if($kt==0)
{
//Lấy thông tin của sản phẩm từ dâtbase theo mã:
$sl="select * from loaibao where mabao='{$_POST['loaibao']}'";
$kq=mysqli_query($link,$sl);
$d=mysqli_fetch_array($kq);
//Lưu thông tin vào session:
$i=count($_SESSION['giohang']);
$_SESSION['giohang'][$i]['mabao']=$d['mabao'];
$_SESSION['giohang'][$i]['tenbao']=$d['tenbao'];
$_SESSION['giohang'][$i]['gia']=$d['gia'];
$_SESSION['giohang'][$i]['soluong']=$_POST['soluong'];
}
header("location:datbao.php");
}
?>

Thursday, February 17, 2022

PHP#26MySQL#22 - Hướng đối tượng Phần 3+4

//lib.php
<?php
class tintuc{
private $link; //chứa mã kết nối
//kết nối:
function connect($host, $user, $pass, $db)
{
$this->link=@mysqli_connect($host,$user,$pass) or die("Không thể kết nối đến Server!");
mysqli_select_db($this->link,$db) or die("Không tồn tại DB này!");
mysqli_query($this->link,"set names 'utf8'");
}
//Xây dựng hàm query:
function query($sl)
{
$kq=mysqli_query($this->link,$sl) or die(mysqli_error());
return $kq;
}
//Xây dựng hàm fetch:
function fetch($kq)
{
$d=mysqli_fetch_array($kq);
return $d;
}
//Hàm num_rows:
function num_rows($kq)
{
return mysqli_num_rows($kq);
}
//Hàm thể loại:Lấy các thể loại theo ngôn ngữ và trạng thái:
function theloai($lang="vi", $anhien=1)
{
$sltl="select * from theloai where (lang='$lang' or '$lang'='') and (AnHien=$anhien or $anhien=-1) order by ThuTu ASC";
$kqtl=$this->query($sltl);
return $kqtl;
}
//Loại tin theo the loại:
function lt_tl($idtl)
{
$sllt="select * from loaitin where AnHien=1 and idTL=$idtl order by ThuTu ASC";
$kqlt=$this->query($sllt);
return $kqlt;
}
//Hàm lấy các tin nổi bật:
function tinnoibat($lang="vi", $sotin=4)
{
$sl="select * from tin where lang='$lang' and TinNoiBat=1 and AnHien=1 order by idTin DESC limit 0,$sotin";
$kq=$this->query($sl);
return $kq;
}
//Hàm lấy các tin xem nhiều:
function tinxemnhieu($lang="vi",$sotin=10)
{
$sl="select idTin,TieuDe from tin where lang='$lang' and AnHien=1 order by SoLanXem DESC limit 0,$sotin";
$kq=$this->query($sl);
return $kq;
}
//Lấy các tin mới nhất theo thể loại:
function tin_tl($idtl,$sotin=6)
{
$sltin="select * from tin where idLT in (select idLT from loaitin where idTL=$idtl and AnHien=1) and AnHien=1 order by idTin DESC limit 0,$sotin";
$kq=$this->query($sltin);
return $kq;
}
//Viết code cập nhật số lần xem của tin:
function solanxem($idtin)
{
$sl="UPDATE tin set SoLanXem=SoLanXem+1 where idTin=$idtin";
$kq=$this->query($sl);
return $kq;
}
//Chi tiết tin:
function chitiettin($idtin)
{
$sl="select idLT, TieuDe, TomTat, Content from tin where idTin=$idtin";
$kq=$this->query($sl);
return $kq;
}
//các tin cũ hơn(lấy 5 tin cũ hơn và cùng loại tin với tin đang mở, sắp xếp từ mới đến cũ
function tincuhon($idlt,$idtin,$sotin)
{
$sl="select * from tin where AnHien=1 and idLT=$idlt and idTin < $idtin order by idTin DESC limit 0,$sotin";
$kq=$this->query($sl);
return $kq;
}
//>Bạn đọc ý kiến:
function bandocykien($idtin)
{
$sl="select * from bandocykien where idTin=$idtin order by Ngay DESC";
$kq=$this->query($sl);
return $kq;
}

//Loạitin theo idLT:
function lt_id($idlt)
{
$sl="select Ten from loaitin where idLT=$idlt and AnHien=1";
$kq=$this->query($sl);
$d=$this->fetch($kq);
return $d['Ten'];
}
//Tin theo Loại:
function tin_loai($idlt)
{
$sl="select idTin from tin where idLT=$idlt and AnHien=1";
$kq=$this->query($sl);
return $kq;
}
//Tin theo Loại , sắp xếp, vị trí:
function tin_loai_vt($idlt,$vt,$sotin)
{
$sl="select * from tin where idLT=$idlt and AnHien=1 order by idTin DESC limit $vt,$sotin";
$kq=$this->query($sl);
return $kq;
}
}
?>