include "config.php"; $result = mysql_query("SELECT * FROM notebookg",$db); $row=mysql_num_rows($result);//查看结果有多少行 if ($row<=1) {$x=$row;} else {$x=2;} $result = mysql_query("select * from notebookg ORDER BY time DESC limit 0,$x",$db);//读取最近2条留言 for ($i=0;$i<=($x-1);$i++) { $name=mysql_result($result,$i,'name'); $time=mysql_result($result,$i,'time'); $title=mysql_result($result,$i,'title'); $nnote=mysql_result($result,$i,'nnote'); echo "◆留言人:$name 时间 $time 主题:$title 内容:$nnote "; } mysql_close($db); ?> |