<html>
<head>
<title>新闻列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body leftMargin=0 topMargin=0 rightmargin=0 ><?php
$db=mysql_connect("localhost","guest","guest");
mysql_select_db("news",$db);
$pagesize=1;
$res=mysql_query("select count(*) from news " ,$db);
$myrow = mysql_fetch_array($res);
$numrows=$myrow[0];
$pages=intval($numrows/$pagesize);
if ($numrows%$pagesize)
$pages++;
if (!isset($page))
$page=1;
if (isset($ys))
if ($ys>$pages)
$page=$pages;
else
$page=$ys;
$offset=$pagesize*($page-1);
$res=mysql_query("select id,title,detail from news order by id desc limit $offset,$pagesize",$db);
if ($myrow = mysql_fetch_array($res))
{
$i=0;
?><style TYPE="text/css">
h2{font-family:"宋体";color:red;text-align:center;font-size:16pt}
td{font-family:"宋体";font-size:10.5pt;color:#000000;}
a{font-family:"宋体";font-size:10.5pt;font-style:normal;}
#jump_page{font-family:"宋体";font-size:10.5pt;}
form{font-family:"宋体";font-size:10.5pt}
button{font-family:"宋体";font-size:10.5pt}
</style>
<center><table width="90%" border="0" cellspacing="0" cellpadding="0">
<caption><?php echo $myrow["title"]; ?>
<hr WIDTH="80%" ALIGN="center"></caption><tr>
<td width="5%" bgcolor="#E1E9FB"></td>
<td width="95%" bgcolor="#E1E9FB"><font color="#FF6666"></font></td>
</tr>
<?php
do {
$i++;
?>
<tr>
<td width="5%" bgcolor="#E6F2FF">
<?
//php echo $i;
?>
</td>
<td width="95%" bgcolor="#E6F2FF">
<p><?php echo $myrow["detail"];?></td>
</tr>
<?php
}
while ($myrow = mysql_fetch_array($res));
echo "</table></center>" ;
}echo "<br>";
echo "<div id=\"jump_page\" align='center'>共有".$pages."页(".$page."/".$pages.")<br>";echo "<br>";
echo "<form action='news.php' method='post'> ";
$first=1;
$prev=$page-1;
$next=$page+1;
$last=$pages;
if ($page>1)
{
echo "<a href='news.php?page=".$first."'>首页</a> ";
echo "<a href='news.php?page=".$prev."'>上一页</a> ";
}
if ($page<$pages)
{
echo "<a href='news.php?page=".$next."'>下一页</a> ";
echo "<a href='news.php?page=".$last."'>尾页</a> ";
}
echo "转到<input type=text name='ys' size='2' value=".$page.">页";
echo "<input type=submit name='Submit' value='确定'>";
echo "</form>";
echo "</div>";?>
</body>
</html>
<head>
<title>新闻列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body leftMargin=0 topMargin=0 rightmargin=0 ><?php
$db=mysql_connect("localhost","guest","guest");
mysql_select_db("news",$db);
$pagesize=1;
$res=mysql_query("select count(*) from news " ,$db);
$myrow = mysql_fetch_array($res);
$numrows=$myrow[0];
$pages=intval($numrows/$pagesize);
if ($numrows%$pagesize)
$pages++;
if (!isset($page))
$page=1;
if (isset($ys))
if ($ys>$pages)
$page=$pages;
else
$page=$ys;
$offset=$pagesize*($page-1);
$res=mysql_query("select id,title,detail from news order by id desc limit $offset,$pagesize",$db);
if ($myrow = mysql_fetch_array($res))
{
$i=0;
?><style TYPE="text/css">
h2{font-family:"宋体";color:red;text-align:center;font-size:16pt}
td{font-family:"宋体";font-size:10.5pt;color:#000000;}
a{font-family:"宋体";font-size:10.5pt;font-style:normal;}
#jump_page{font-family:"宋体";font-size:10.5pt;}
form{font-family:"宋体";font-size:10.5pt}
button{font-family:"宋体";font-size:10.5pt}
</style>
<center><table width="90%" border="0" cellspacing="0" cellpadding="0">
<caption><?php echo $myrow["title"]; ?>
<hr WIDTH="80%" ALIGN="center"></caption><tr>
<td width="5%" bgcolor="#E1E9FB"></td>
<td width="95%" bgcolor="#E1E9FB"><font color="#FF6666"></font></td>
</tr>
<?php
do {
$i++;
?>
<tr>
<td width="5%" bgcolor="#E6F2FF">
<?
//php echo $i;
?>
</td>
<td width="95%" bgcolor="#E6F2FF">
<p><?php echo $myrow["detail"];?></td>
</tr>
<?php
}
while ($myrow = mysql_fetch_array($res));
echo "</table></center>" ;
}echo "<br>";
echo "<div id=\"jump_page\" align='center'>共有".$pages."页(".$page."/".$pages.")<br>";echo "<br>";
echo "<form action='news.php' method='post'> ";
$first=1;
$prev=$page-1;
$next=$page+1;
$last=$pages;
if ($page>1)
{
echo "<a href='news.php?page=".$first."'>首页</a> ";
echo "<a href='news.php?page=".$prev."'>上一页</a> ";
}
if ($page<$pages)
{
echo "<a href='news.php?page=".$next."'>下一页</a> ";
echo "<a href='news.php?page=".$last."'>尾页</a> ";
}
echo "转到<input type=text name='ys' size='2' value=".$page.">页";
echo "<input type=submit name='Submit' value='确定'>";
echo "</form>";
echo "</div>";?>
</body>
</html>
解决方案 »
- 最新乱码问题 大家看看
- spring事物问题
- jsp里的request和session是线程安全的么?
- Tomcat Web Application Manager的问题
- 发邮件 繁体中文 乱码
- struts中<html:text>标签的问题,请求解答
- jsp分页显示的问题:如果显示的表没有ID顺序号,怎么做?
- 有大虾了解"广州市奥杰信息技术有限公司"的吗?
- 在vb中是否可以调用javabean写的业务层?
- 如何检测<input type=file name=filename>提交的内容不为随意输入的内容,以免出错???
- 有谁用java 做过动态显示数据的二维,三维图表?给提个思路.谢谢.
- 为何jsp中对所调用的bean的包名和类名敏感?
echo "</table></center>" ;
这句是什么意思???
改成echo "</table></center>" ;
就行了吧,
再试试吧
我不知道你的数据结构没法帮你调试呀
假如有一个文本框,name为content;
录入时作如下转换:
$content=ereg_replace(" "," ",$content);
$content=ereg_replace("\n","<br>",$content);
读出时作如下转换:
$content=ereg_replace(" "," ",$content);
$content=ereg_replace("<br>","\n",$content);
$content=ereg_replace(" "," ",$content);
$content=ereg_replace("\n","<br>",$content);录入时不要转换!