第二部分:读取数据库,并实现循环输出
<?php $sql="select * from liuyan order by ly_id desc"; $conn=mysql_query($sql,$connec); while($rs=mysql_fetch_array($conn)){ ?> <table width="476" border="1" cellspacing="0" cellpadding="0"> <tr> <td width="135" height="30"><div align="center">留言主题</div></td> <td width="204" height="30"><div align="center">留言时间</div></td> <td width="129" height="30"><div align="center">留言人</div></td> </tr> <tr bgcolor="#CC9999"> <td height="30"><?= $rs["ly_title"]?> <div align="center"></div></td> <td height="30"><?= $rs["ly_time"]?> <div align="center"></div></td> <td height="30"><?= $rs["ly_author"]?> <div align="center"></div></td> </tr> <tr> <td height="30"><div align="center"><a href="huifu.php?id=<?php echo $rs["ly_id"]?>">回复留言</a></div></td> <td height="30"><div align="center"><a href="viewhuifu.php?id=<?php echo $rs["ly_id"]?>">查看回复信息</a></div></td> <td height="30"><div align="center">已有回复</div></td> </tr> </table> <?php } ?>