Saturday, 8 January 2022

PHP#16MySQL#12 - index.php, include

https://app.mediafire.com/fwx971t2bbggr 

//index.php

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>Untitled Document</title>

<link href="c2.css" rel="stylesheet" type="text/css">

</head>


<body>

<div id="container">

<div id="header"> </div>

   <div id="thanhmenu"><?php include("menu.php");?></div>

  <div id="main1">

    <div id="main1_1"><?php include("tinnoibat.php");?></div>

<div id="main1_2"><?php include("tinxemnhieu.php");?></div>

<div id="main1_3">  </div>

</div>

<div id="quangcao"> </div>

<div id="main2">

<div id="main2_1">

<?php 

if(isset($_GET['key']))

{

switch($_GET['key'])

{

case "ctt": include("chitiettin.php");break;

case "lt": include("loaitin.php");break;

}

}

else include("tinmoi.php");?></div>

        <div id=main2_2>   

            <div id="loihayydep"> </div>

   <div id="divtimkiem"> </div>

            <div id="divbinhchon"> </div>

   <div id="quangcao2"> </div>

    </div>

</div>

<div id="footer">  </div>

</div> <!-- container -->

</body>

</html>


include chèn vào trong index.php:

//c2.css

@charset "utf-8";

body {

font-family: "Times New Roman", Times, serif;

font-size: 16px;

text-align: center;

}

#container {

margin: auto;

width: 960px;

text-align: left;

}

#header{ height:150px;border:solid 1px #033;background:no-repeat url(banner/banner1.jpg)   

}

#thanhmenu{ height:41px; background-color:#004080;  margin-top:5px; }

#main1_1{ float:left; width:460px; background-color:#9CF; height:300px}

#main1_2{ float:left; width:240px; background-color:#CCC; 

  height:300px; overflow:hidden; margin-left:5px}

#main1_3{

float:left;

width:250px;

margin-left:5px;

height:300px;

background-color: #CCCC99;

#quangcao{ height:90px; margin-top:3px; background-color:#6CC; clear:left   }

#main2_1 {

width:660px;

float:left;

min-height:600px;

background-color: #669999;

}

#main2_2 { width:300px; float:left; background-color:#369;min-height:600px}

#footer{ height:150px; background-color:#036; clear:both; text-align:center; color:#FFFF33; }


#tinxemnhieu p{ 

margin-top:0px; margin-bottom:0px; 

border-bottom:solid 1px #936; white-space:nowrap; 

padding-left:5px; padding-top:6px; padding-bottom:6px;}

#tinxemnhieu a{ text-decoration:none; color:#036; }

#tinxemnhieu a:hover{color:#930}


#tinnoibat{ width:460px}

#tinnoibat #top1 { height:160px; text-align:justify; 

   padding-right:5px; color:#036;  font-size:16px}

#tinnoibat #top1 a { color:#900; text-decoration:none; font-size:18px}

#tinnoibat #top1 a:hover{ color:#F60; text-decoration:underline} 

#tinnoibat #top1 p{ margin-top:0px; margin-bottom:10px}

#tinnoibat #top1 img { margin-right:5px}

#tinnoibat #top3 div { width:33.3%; float:left; text-align:center}

#tinnoibat #top3  a { text-decoration:none; color:#C60}

#tinnoibat #top3  a:hover { text-decoration:underline; color:#069}


#tinmoi .theloai{

font-size:18px;

background-color:#003300;

color:#FFF;

padding-top:5px;

padding-bottom:5px;

clear:left

}

#tinmoi .theloai a{color:#9C0; text-decoration:none; margin-left:5px; font-size:16px;}

#tinmoi .theloai a:hover{ color:#6CC; text-decoration:underline; }

#tinmoi #tinmoinhat {

width:330px;

float:left;

color:#CCCCCC;

height:175px;

overflow:hidden

}

#tinmoi #tinmoinhat p{ text-align:justify; padding-right:5px}

#tinmoi #tinmoinhat a {

text-decoration:none;

color:#CC3333;

font-size:16px;

font-weight:bold

#tinmoi #tinmoinhat a:hover{ text-decoration:underline; color:#C09}


#tinmoi #tinmoitieptheo { float:left; width:330px; height:175px; overflow:hidden; white-space:nowrap  }

#tinmoi #tinmoitieptheo p { margin-top:10px; margin-bottom:10px; padding-left:5px; }

#tinmoi #tinmoitieptheo a{

text-decoration:none;

color:#CC3358

}

#tinmoi #tinmoitieptheo a:hover{text-decoration:underline; color:#C09}


#loihayydep { 

background-color:#036; color:#9C0;padding:10px; 

}

#loihayydep p { margin-top:0px; margin-bottom:10px}

#loihayydep .caption {

color:#6C0; text-transform:uppercase; 

border-bottom:solid 1px #6C0; font-weight:bold; margin-top:0px;

}


#divtimkiem {

background-color: #A7D27B;

padding-top:8px; padding-bottom:8px;}

#divtimkiem #formtimkiem {margin: 0px;}

#divtimkiem #tukhoa {

background: #693; color: #FFFF00;

border: solid 1px #0FF;

padding-top: 4px; padding-bottom: 4px;

width: 225px; margin-left:5px;

}

#divtimkiem #btntimkiem { 

background-color:#CC0000;  color:#00FFCC; 

width:60px;  padding:2px;  border:solid 1px #336699}


#divbinhchon { background-color:#036; color:#9C0;padding:10px;}

#divbinhchon .caption {

color:#6C0; text-transform:uppercase; 

border-bottom:solid 1px #6C0; font-weight:bold; margin-top:0px;

}

#copyright {

display: none;

}


//menu.php

    <link type="text/css" href="menu/menu.css" rel="stylesheet" />
    <script type="text/javascript" src="menu/jquery.js"></script>
    <script type="text/javascript" src="menu/menu.js"></script>


<style type="text/css">
* { margin:0;
    padding:0;
}
body { background:rgb(74,81,85); }
div#menu { margin:5px auto; }
div#copyright {
    font:11px 'Trebuchet MS';
    color:#fff;
    text-indent:30px;
    padding:40px 0 0 0;
display:none;
}
div#copyright a { color:#00bfff; }
div#copyright a:hover { color:#fff; }
</style>

<div id="menu">
    <ul class="menu">
        <li><a href="index.php" class="parent"><span>Trang Chủ</span></a></li>
        <?php 
include("connect.php");
$sltl="select * from theloai where lang='vi' and AnHien=1 order by ThuTu ASC";
$kqtl=mysqli_query($link,$sltl);
$tongtl=mysqli_num_rows($kqtl);
while($dtl=mysqli_fetch_array($kqtl))
{
$tongtl--;
?>
        <li <?php if($tongtl==0) echo '"last"';?>><a href="#" class="parent"><span><?php echo $dtl['TenTL'];?></span></a>
            <ul>
          <?php 
$slloai="select * from loaitin where idTL={$dtl['idTL']} order by ThuTu ASC";
$kqloai=mysqli_query($link,$slloai);
while($dloai=mysqli_fetch_array($kqloai)){
?>
                <li><a href="index.php?key=lt&idLT=<?php echo $dloai['idLT'];?>"><span><?php echo $dloai['Ten'];?></span></a></li> <?php }?>
                
            </ul>
        </li>
        <?php }?>
        
    </ul>
</div>

<div id="copyright">Copyright &copy; 2011 <a href="http://apycom.com/">Apycom jQuery Menus</a></div>


//tinnoibat.php

<style type="text/css">
<!--
#tinnoibat {
border: 1px solid #993300;
width: 460px;
min-height: 300px;
}
#tinnoibat #top1 {
min-height: 140px;
margin-bottom: 5px;
border-bottom-width: 1px;
border-bottom-style: dotted;
border-bottom-color: #993300;
}
#tinnoibat #top3 div {
width: 33.3%;
float: left;
text-align: center;
}
#tinnoibat #top3 a {
color: #006699;
text-decoration: none;
}
#tinnoibat #top1 img {
margin-right: 5px;
}
#tinnoibat #top1 p {
margin-top: 0px;
}
#tinnoibat #top1 a {
font-size: 18px;
color: #CC0033;
text-decoration: none;
}
-->
</style>

<div id="tinnoibat">
<?php 
include("connect.php");
$sl="select * from tin where lang='vi' and TinNoiBat=1 and AnHien=1 order by idTin DESC limit 0,4";
$kq=mysqli_query($link,$sl);
//Lấy dòng đầu tiên( lấy ra rồi là lấy luôn)
$d=mysqli_fetch_array($kq)

?>
    <div id="top1">
    <img width=150 height=120 align=left src="<?php echo $d['urlHinh'];?>" />
        <p><a href="index.php?key=ctt&idtin=<?php echo $d['idTin'];?>"> <?php echo $d['TieuDe'];?> </a> </p>
        <?php echo $d['TomTat'];?>    
    </div> 

    
   
    <div id="top3">
    <?php 
while($d=mysqli_fetch_array($kq))
{
?>
<div> 
        <img src="<?php echo $d['urlHinh'];?>" width="140" height="90" /><br />
         <a href="index.php?key=ctt&idtin=<?php echo $d['idTin'];?>"> <?php echo $d['TieuDe'];?> </a> 
         </div>
         <?php }?>
    </div>

</div>

//tinxemnhieu.php
<style type="text/css">
<!--
#tinxemnhieu {
width: 250px;
border: 1px solid #0099CC;
overflow: hidden;
white-space: nowrap;
}
#tinxemnhieu  h4 {
background-color: #0099CC;
margin-top: 0px;
margin-bottom: 0px;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 10px;
color: #FFFF00;
}
#tinxemnhieu a {
color: #CC3399;
text-decoration: none;
}
#tinxemnhieu a:hover {
color: #FFCC00;
}
#tinxemnhieu p {
margin-top: 0px;
margin-bottom: -1px;
background-color: #FFFFCC;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 10px;
border: 1px solid #0099CC;
}
-->
</style>


<div id="tinxemnhieu">
<h4>TIN XEM NHIỀU</h4>
<?php 
$link=@mysqli_connect("localhost","root","") or die("Không tìm thấy Sever");
mysqli_select_db($link,"tintuc") or die("Không tồn tại DB");
mysqli_query($link,"set names 'utf8'");
$sl="select * from tin  WHERE lang='vi' and AnHien=1 order by SoLanXem DESC limit 0,10";
$kq=mysqli_query($link,$sl);
while($d=mysqli_fetch_array($kq))
{
?>
<p> <a href="index.php?key=ctt&idtin=<?php echo $d['idTin'];?>"> <?php echo $d['TieuDe'];?> </a>  </p>
<?php }?>
</div>

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

<body>
<?php
if(isset($_GET['idtin']))
{
$idtin=$_GET['idtin'];
include("connect.php");
$sltin2="select TieuDe, TomTat, Content from tin where idTin=$idtin";
$kqtin2=mysqli_query($link,$sltin2);
$dtin2=mysqli_fetch_array($kqtin2)
?>
<h1 align="center"><?php echo $dtin2['TieuDe'];?></h1>
<div><?php echo $dtin2['TomTat'];?></div>
<div><?php echo $dtin2['Content'];?></div>
<?php }?>
</body>
</html>

//loaitin.php

<style>
#main_loai{ width:660px;}
.loai_left{ width:250px; float:left; height:160px;}
.loai_right{ width:390px; float:right; height:160px; overflow:hidden;}
.clear{ clear:both; margin-bottom:10px;}
</style>
</head>

<body>
<?php 
if(isset($_GET['idLT']))
{
include("connect.php");
$idLT=$_GET['idLT'];
$kq1=mysqli_query($link,"select Ten from loaitin where idLT=$idLT");
$d1=mysqli_fetch_array($kq1);
//Phân trang:
$stin=10;
$kq=mysqli_query($link,"select idTin from tin where idLT=$idLT and AnHien=1");
$tst=ceil(mysqli_num_rows($kq)/$stin);
//Tính trang hiện tại:
if(isset($_GET['page'])) $page=$_GET['page'];
else $page=1;
//Tính vị trí lấy dữ liệu:
$vt=($page-1)*$stin;
?>
<div id="main_loai">
    <h2><?php echo $d1['Ten'];?></h2>
    <?php 
$sl2="select * from tin where idLT=$idLT and AnHien=1 order by idTin DESC limit $vt,$stin";
$kq2=mysqli_query($link,$sl2);
while($d2=mysqli_fetch_array($kq2)){
?>
    <div class="loai_left"><img src="<?php echo $d2['urlHinh'];?>" width="250" height="160" alt=""/></div>
    <div class="loai_right">
    <h3><?php echo $d2['TieuDe'];?></h3>
    <div><?php echo $d2['TomTat'];?></div>
    </div>
    <div class="clear"></div>
    <?php }?>
<?php }?>

    <div>Trang <?php for($i=1;$i<=$tst;$i++){?><a href="index.php?key=lt&idLT=<?php echo $idLT;?>&page=<?php echo $i;?>"><?php echo $i;?></a> <?php }?></div>
</div>


//tinmoi.php

<style type="text/css">

#tinmoi {width: 660px;}

#tinmoi .tinmoinhat {
width:330px;
float:left;
color:#336699;
height: 175px;
overflow: hidden;
}

#tinmoi .tinmoitieptheo {
float:left;
width:329px;
height: 175px;
overflow: hidden;
white-space: nowrap;
border-left: dotted 1px #030;
}
#tinmoi .theloai {
font-size:18px; background-color:#003300; color:#FFF;
padding-top:5px; padding-bottom:5px; clear:left
}
#tinmoi .theloai a {
color:#9C0; text-decoration:none; margin-left:5px; font-size:16px;}
#tinmoi .theloai a:hover{ color:#6CC; text-decoration:underline; }

#tinmoi  .tinmoinhat a {
text-decoration:none; color:#003366; 
font-size:16px; font-weight:bold; 
}
#tinmoi .tinmoinhat a:hover{ text-decoration:underline; color:#C09}
#tinmoi .tinmoinhat img { margin-right: 5px; }

#tinmoi .tinmoitieptheo a {
text-decoration:none;
color:#003333
}
#tinmoi .tinmoitieptheo a:hover{text-decoration:underline; color:#C09}
#tinmoi .tinmoitieptheo p {
margin-top:10px; margin-bottom:10px; padding-left:5px;
}

</style>
</head>

<body>
<div id="tinmoi">
<?php 
include('connect.php');
$sl="select * from theloai where lang='vi' and AnHien=1 order by ThuTu ASC";
$kq=mysqli_query($link,$sl);
while($d=mysqli_fetch_array($kq))
{
?>
  <div class="theloai"> <?php echo $d['TenTL'];

  $sl2="select * from loaitin where idTL={$d['idTL']} order by ThuTu ASC";
  $kq2=mysqli_query($link,$sl2);
  while($d2=mysqli_fetch_array($kq2))
  {
  ?> 
      <a href="index.php?key=lt&idLT=<?php echo $d2['idLT'];?>"> <?php echo $d2['Ten'];?>  </a> <?php }?>
  </div>

  <!-- div theloai -->
  
  <?php 
  $sltin="select * from tin where idLT in (select idLT from loaitin where idTL={$d['idTL']} and AnHien=1) and AnHien=1 order by idTin DESC limit 0,6";
$kqtin=mysqli_query($link,$sltin);
$dtin=mysqli_fetch_array($kqtin);
  ?>
  <div class="tinmoinhat">

    <a href="index.php?key=ctt&idtin=<?php echo $dtin['idTin'];?>"> <?php echo $dtin['TieuDe'];?> </a>
    <p> <img src="<?php echo $dtin['urlHinh'];?>" width="80" height="80" align="left" />
      <?php echo $dtin['TomTat'];?>      
    </p>
  </div> <!-- tinmoinhat -->
  <div class="tinmoitieptheo">
  <?php 
  while($dtin=mysqli_fetch_array($kqtin)){
  ?>
    <p> <a href="index.php?key=ctt&idtin=<?php echo $dtin['idTin'];?>"> <?php echo $dtin['TieuDe'];?>  </a> </p> <?php }?>
  </div>  <!-- div id=tinmoitieptheo -->
  <?php }?>
  


</div><!-- tinmoi -->

0 comments:

Post a Comment