<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>

解决方案 »

  1.   

    while ($myrow = mysql_fetch_array($res));
    echo "</table></center>" ;
    这句是什么意思???
    改成echo "</table></center>" ;
    就行了吧,
    再试试吧
    我不知道你的数据结构没法帮你调试呀
      

  2.   

    代码如下:
    假如有一个文本框,name为content;
    录入时作如下转换:
    $content=ereg_replace(" ","&nbsp;",$content);
    $content=ereg_replace("\n","<br>",$content);
    读出时作如下转换:
    $content=ereg_replace("&nbsp;"," ",$content);
    $content=ereg_replace("<br>","\n",$content);
      

  3.   

    建议你读出时做如下转换
    $content=ereg_replace(" ","&nbsp;",$content);
    $content=ereg_replace("\n","<br>",$content);录入时不要转换!
      

  4.   

    能给一个用textarea文本框输入文章并显示出来的代码吗?