conn.php
<?php
$conn = mysqli_connect("127.0.0.1","root","root","dbstudy") or die("数据库连接失败!");
mysqli_query($conn,"SET NAMES UTF8");
?>
news.php
<?php
include_once("conn.php");
session_start();
?>
<!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>无标题文档</title>
</head>
<body>
<ul><?php
$selectSQLforNews = "SELECT * FROM `yu_type` ORDER BY `type_id`=1 DESC ";
$recodeforNews = mysqli_query($conn,$selectSQLforNews);
$rowforNews = mysqli_fetch_array($recodeforNews);
?>
<li><h4> <?php $str="一二三四";echo substr($str,0,3);?>、<?=$rowforNews["type_name"]?></h4><>
<li>
<ul><?php
$selectSQLforNews = "SELECT * FROM `yu_news` WHERE `type_id`=1 ORDER BY `news_hit`DESC LIMIT 0,5";
$recodeforNews = mysqli_query($conn,$selectSQLforNews);
while ($rowforNews = mysqli_fetch_array($recodeforNews))
{
?>
<li>·<?=$rowforNews["news_title"]?>[<?=$rowforNews["news_hit"]?>]<>
<?php
}
mysqli_free_result($recodeforNews);
?>
</ul>
</li>
<?php
$selectSQLforNews = "SELECT * FROM `yu_type` ORDER BY `type_id`=2 DESC ";
$recodeforNews = mysqli_query($conn,$selectSQLforNews);
$rowforNews = mysqli_fetch_array($recodeforNews);
?>
<li><h4> <?php $str="一二三四";echo substr($str,3,3);?>、<?=$rowforNews["type_name"]?></h4> </li>
<li>
<ul>
<?php
$selectSQLforNews = "SELECT * FROM `yu_news` WHERE `type_id`=2 ORDER BY `news_hit` DESC LIMIT 0,5";
$recodeforNews = mysqli_query($conn,$selectSQLforNews);
while ($rowforNews = mysqli_fetch_array($recodeforNews))
{
?>
<li>· <?=$rowforNews["news_title"]?>[<?=$rowforNews["news_hit"]?>] </li>
<?php
}
mysqli_free_result($recodeforNews);
?>
</ul>
</li>
<?php
$selectSQLforNews = "SELECT * FROM `yu_type` ORDER BY `type_id`=3 DESC ";
$recodeforNews = mysqli_query($conn,$selectSQLforNews);
$rowforNws = mysqli_fetch_array($recodeforNews);
?>
<li><h4><?php $str="一二三四";echo substr($str,6,3);?>、<?=$rowforNews["type_name"]?></h4> </li>
<li>
<ul>
<?php
$selectSQLforNews = "SELECT * FROM `yu_news` WHERE `type_id`=3 ORDER BY `news_hit` DESC LIMIT 0,5";
$recodeforNews = mysqli_query($conn,$selectSQLforNews);
while ($rowforNews = mysqli_fetch_array($recodeforNews))
{
?>
<li>· <?=$rowforNews["news_title"]?>[<?=$rowforNews["news_hit"]?>] </li>
<?php
}
mysqli_free_result($recodeforNews);
?>
</ul>
</li>
<?php
$selectSQLforNews = "SELECT * FROM `yu_type` ORDER BY `type_id`=4 DESC ";
$recodeforNews = mysqli_query($conn,$selectSQLforNews);
$rowforNews = mysqli_fetch_array($recodeforNews);
?>
<li><h4><?php $str="一二三四";echo substr($str,9,3);?>、<?=$rowforNews["type_name"]?></h4> </li>
<li>
<ul><?php
$selectSQLforNews = "SELECT * FROM `yu_news` WHERE `type_id`=4 ORDER BY `news_hit` DESC LIMIT 0,5";
$recodeforNews = mysqli_query($conn,$selectSQLforNews);
while ($rowforNews = mysqli_fetch_array($recodeforNews))
{
?>
<li>·<?=$rowforNews["news_title"]?>[<?=$rowforNews["news_hit"]?>] </li>
<?php
}
mysqli_free_result($recodeforNews);
?>
</ul>
</li>
</ul>
<?php
mysqli_close($conn);
?>
</body>
</html>