<?php 
class trangchu extends DB 

{
	public function theloai($idtl)
	{
		$qr = "SELECT * FROM bangtin  WHERE idTL= '$idtl' ORDER BY Ngay DESC";
		return mysqli_query($this -> con,$qr);
	}
	public function lichtuan($idtl)
	{
		$qr = "SELECT * FROM bangtin  WHERE idTL= '$idtl' ORDER BY Ngay DESC LIMIT 0,1";
		return mysqli_query($this -> con,$qr);
	}
	public function tintrongloai($idtl,$idloaitin)
	{
		$qr = "SELECT * FROM bangtin  WHERE idTL= '$idtl' AND idLT = $idloaitin  ORDER BY Ngay DESC";
		return mysqli_query($this -> con,$qr);
	}
	public function theloaikd($idtl)
	{
		$qr = "SELECT * FROM theloai  WHERE idTL= $idtl";
		return mysqli_query($this -> con,$qr);
	}
	public function tinmoinhat_theloai($idtl,$sl)
	{
		$qr = "SELECT * FROM bangtin  WHERE idTL= '$idtl' OR idTL2 ='$idtl' ORDER BY Ngay DESC LIMIT 0,".$sl."";
		return mysqli_query($this -> con,$qr);
	}
	public function tintheloai($idtl)
	{
		$qr = "SELECT * FROM bangtin  WHERE idTL= '$idtl'ORDER BY thutu ASC ";
		return mysqli_query($this -> con,$qr);
	}

	public function tinmoinhat_offset($idtl,$offset,$sl)
	{
		$qr = "SELECT * FROM bangtin  WHERE idTL= '$idtl' OR idTL2 ='$idtl' ORDER BY Ngay DESC LIMIT $offset,".$sl."";
		return mysqli_query($this -> con,$qr);
	}
	public function tinmoinhat_loaitin($idlt,$sl)
	{
		$qr = "SELECT * FROM bangtin  WHERE idLT= '$idlt' ORDER BY Ngay DESC LIMIT 0,".$sl."";
		return mysqli_query($this -> con,$qr);
	}
	public function anhquangcao()
	{
		$qr = "SELECT * FROM thongbao ORDER BY vitri ASC  ";
		return mysqli_query($this-> con,$qr);
	}
	public function lienket()
	{
		$qr = "SELECT * FROM lienket ORDER BY vitri ASC  ";
		return mysqli_query($this-> con,$qr);
	}
	public function slide()
	{
		$qr = "SELECT * FROM bangslide ";
		return mysqli_query($this-> con,$qr);
	}
	public function chitiettin($idtin)
	{
		$qr = "SELECT * FROM bangtin WHERE idTin = '$idtin' ";
		return mysqli_query($this-> con,$qr);
	}
	public function theloai_phantrang($idtl,$from,$sotin)
	{
		$qr = "SELECT * FROM bangtin  WHERE idTL= '$idtl' OR idTL2 = '$idtl' ORDER BY Ngay DESC LIMIT $from,$sotin";
		return mysqli_query($this -> con,$qr);
	}
	public function tincungloai($idtin,$idtl)
	{
		$qr = "SELECT * FROM bangtin WHERE idTin <> '$idtin' AND idTL = '$idtl' ORDER BY Ngay DESC LIMIT 0,5 ";
		return mysqli_query($this -> con,$qr);
	}
	public function luotxem($idtin)
	{
		$qr = "UPDATE bangtin SET SoLanXem = SoLanXem + 1 WHERE idTin = $idtin ";
		mysqli_query($this -> con,$qr);
	}
	public function timkiem($tukhoa)
	{
		$qr = "SELECT * FROM bangtin WHERE TieuDe LIKE '%$tukhoa%'  ORDER BY Ngay DESC LIMIT 0,50";
		return mysqli_query($this -> con,$qr);
	}
	public function login()
	{
		$qr = "SELECT * FROM tueba_users ";
		return mysqli_query($this -> con,$qr);
	}
	public function updatelogin($iduser,$thoigian)
	{
		$qr = "UPDATE tueba_users SET lastlogin = '$thoigian' WHERE iduser = $iduser ";
		mysqli_query($this -> con,$qr);
	}
}	
 ?>