⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 news.php

📁 网上书店网站系统
💻 PHP
字号:
<?php
function conndb()
{
	$db=@mysql_pconnect("localhost","root","307910");
	if($db==false)
	{
		print "Database failed!";
		exit();
	}
	return $db;
}?>
<html>
<head>
<title>新闻快讯</title>
<meta content="text/html; charset=gb2312" http-equiv=Content-Type>
</head>
<?
require("index.html.inc");
?>
<body>
<table align=center width="70%">
<tbody>
<tr><td bgcolor=#8cc9ec align=center colspan=8>新闻分类</td></tr>
<tr>
<td bgcolor=#8cc9ec align=center><A href="news.php?cata=guoji">国际</A></td>
<td bgcolor=#8cc9ec align=center><A href="news.php?cata=guonei">国内</A></td>
<td bgcolor=#8cc9ec align=center><A href="news.php?cata=shehui">社会</A></td>
<td bgcolor=#8cc9ec align=center><A href="news.php?cata=caijing">财经</A></td>
<td bgcolor=#8cc9ec align=center><A href="news.php?cata=diannao">电脑</A></td>
<td bgcolor=#8cc9ec align=center><A href="news.php?cata=tiyu">体育</A></td>
<td bgcolor=#8cc9ec align=center><A href="news.php?cata=wenhua">文化</A></td>
<td bgcolor=#8cc9ec align=center><A href="news.php?cata=yule">娱乐</A></td>
<tr><t colspan=8>
<table align=center>
<tbody>
<?
if(isset($from))
{
	$db=conndb();
	if($from+10<=$total)
	{
		$step=10;
	}
	else
	{
		$step=$total-$from;
	}
	print "本页显示新闻:$from - ".($from+$step-1)."(共有新闻 $total 条)";
	$res=@mysql_db_query("newsystem","select title from $cata order by touch limit $from,$step",$db);
	for($i=0;$i<$step;$i++)
	{
		$row=@mysql_fetch_row($res);
		print "<tr><td><img src=\"news.gif\">&nbsp;&nbsp;";
		print "<A href=\"contents.php?cata=$cata&title=$row[0]&from=$from";
		print "&total=$total\">$row[0]</A></td></tr>\n";
	}
	print "<tr><td><A href=\"$PHP_SELF?cata=$cata&from=0&total=$total\">";
	print "首页</A>&nbsp;&nbsp;";
	if($total>20)
	{
		print "<tr><td><A href=\"$PHP_SELF?cata=$cata&from=".($from-10)."&total=$total\">";
		print "上一页</A>&nbsp;&nbsp;";
	}
	if($total>$from+10)
	{
		print "<tr><td><A href=\"$PHP_SELF?cata=$cata&from=".($from+10)."&total=$total\">";
		print "下一页</A>&nbsp;&nbsp;";
		print "<tr><td><A href=\"$PHP_SELF?cata=$cata&from=".($total-$total%10)."&total=$total\">";
		print "末页</A>";
	}
	else
	{
		print "<tr><td><A href=\"$PHP_SELF?cata=$cata&from=".($total-$total%10)."&total=$total\">";
		print "末页</A>";
	}
	print "</td></tr>";
}
else if(isset($cata))
{
	$res=@mysql_db_query("newsystem","select title from $cata order by touch",$db);
	$total=@mysql_num_rows($res);
	if($total==0)
	{
		print "<tr><td colspan=8 align=center>当前还没有最新消息!</td></tr>\n";
	}
	else
	{
		if($total>10)
		{
			$step=10;
		}
		else
		{
			$step=$total;
		}
	print "本页显示新闻:0 - ".($step-1)."(共有新闻 $total 条)";
	for($i=0;$i<$step;$i++)
	{
		$row=@mysql_fetch_row($res);
		print "<tr><td><img src=\"news.gif\">&nbsp;&nbsp;";
		print "<A href=\"contents.php?cata=$cata&title=$row[0]&from=$from";
		print "&total=$total\">$row[0]</A></td></tr>\n";
	}
	print "<tr><td>";

	if($total>10)
	{	
		print "<A href=\"$PHP_SELF?cata=$cata&from=0&total=$total\">";
		print "首页</A>&nbsp;&nbsp;";
	}
	if($total>20)
	{
		print "<tr><td><A href=\"$PHP_SELF?cata=$cata&from=10&total=$total\">";
		print "下一页</A>&nbsp;&nbsp;";
		print "<tr><td><A href=\"$PHP_SELF?cata=$cata&from=".($total-$total%10)."&total=$total\">";
		print "末页</A>";
	}
	if($total>10&&$total<=20)
	{
		print "<tr><td><A href=\"$PHP_SELF?cata=$cata&from=10&total=$total\">";
		print "末页</A>";
	}
	print "</td></tr>";
	}
}
else
{
	print "<tr><td colspan=8 align=center>请单击具体的新闻类别</td></tr>";
}
?>
</tbody></table></td></tr>
</tbody></table>
<?
require("foot.html.inc");
?>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -