<br> 样子有点像chinaasp,其实差多了.bbsshow.php<br> <br> <html><br> <head><br> <title>BBS</title><br> <link href="forum.css" rel="stylesheet" type="text/css"><br> <script language=javascript><br> <!--<br> function formcheck()<br> { <br> if (document.showform.pageno.value == "")<br> {<br> alert("请写入合适的页数.");<br> return (false);<br> }<br> else <br> {<br> var o=document.showform.pageno.value;<br> var checkOK = "0123456789";<br> var allValid = true;<br> for (i = 0; i < o.length; i++)<br> {<br> ch = o.charAt(i);<br> for (j = 0; j < checkOK.length; j++)<br> if (ch == checkOK.charAt(j))<br> break;<br> if (j == checkOK.length)<br> {<br> allValid = false;<br> break;<br> }<br> }<br> if (!allValid)<br> {<br> alert("请写入合适的页数.");<br> document.showform.pageno.focus();<br> return (false);<br> }<br> return (true); <br> }<br> }<br> //--><br> </script><br> </head><br> <body bgcolor=#ffffe0><br> <?<br> $layernum=0;<br> $showstring="";<br> $child_ID[0]=0;<br> $tmp[0]=0;<br> <br> function showstr()<br> {<br> global $layernum,$child_ID,$tmp,$Connection_ID;<br> $tmpnum=1;<br> while(odbc_fetch_row($child_ID[$layernum],$tmpnum)>=1) <br> {<br> $showlen = strlen(odbc_result($child_ID[$layernum],content));<br> echo "<li><image src=images/icon".odbc_result($child_ID[$layernum],messagetype).".gif> ";<br> echo "<a href=bbsrepeat.php?ID=".odbc_result($child_ID[$layernum],ID)." target=input>".odbc_result($child_ID[$layernum],subject)." ";<br> if($showlen <1 )<br> { <br> echo "<无内容> ";<br> }<br> <br> echo "</a>【<b>".odbc_result($child_ID[$layernum],name)."</b>】 <i>".odbc_result($child_ID[$layernum],date_time);<br> echo "</i> [ID:".odbc_result($child_ID[$layernum],ID)." 点击:".odbc_result($child_ID[$layernum],hitnum);<br> echo "] (".$showlen." bytes) <font color=red>(".odbc_result($child_ID[$layernum],childnum).")</font>";<br> if (substr(odbc_result($child_ID[$layernum],date_time),0,10)==substr(date("Y-m-d"),0,10)) <br> {<br> echo " <img width=30 height=15 src=images/new2.gif>";<br> }<br> echo "</li><br>";<br> <br> if(odbc_result($child_ID[$layernum],childnum) <> 0 )<br> {<br> echo "<ul>";<br> $strQuery = "SELECT * FROM bbsmessage Where parentID=".odbc_result($child_ID[$layernum],ID);<br> $layernum = $layernum + 1;<br> $tmp[$layernum]=$tmpnum;<br> $child_ID[$layernum]=odbc_exec($Connection_ID,$strQuery);<br> showstr();<br> $tmpnum=$tmp[$layernum];<br> $layernum = $layernum - 1;<br> echo "</ul>"; <br> }<br> $tmpnum++;<br> }<br> odbc_free_result($child_ID[$layernum]);<br> }<br> ?><br> <?<br> $strQuery ="SELECT * FROM bbsmessage Where parentID=0 ORDER BY date_time DESC";<br> $Connection_ID=odbc_connect("bbs","","");<br> $Result_ID=odbc_exec($Connection_ID,$strQuery);<br> $recordcount=odbc_num_rows($Result_ID);<br> <br> if($recordcount<1) <br> {<br> echo "<br><br><br><p align=center><font size=+3 color=red>论坛刚开张,欢迎你第一个光顾!</font></p>";<br> }<br> else<br> {<br> $pagesize = 10;<br> <br> if ($recordcount%$pagesize==0)<br> {<br> $count=$recordcount/$pagesize;<br> }else<br> {<br> $count=($recordcount-$recordcount%$pagesize)/$pagesize+1;<br> }<br> if($pageno=="") <br> { <br> $pageno=1; <br> }elseif($pageno>$count)<br> {<br> $pageno=1; <br> }<br> ?> <br> <br> <table border="1" width="100%" align=center cellspacing="0" bordercolordark="#FFFFFF" bordercolorlight="#000000" bgcolor="#FAD185" cellpadding="3"><br> <tr><br> <td nowrap align="center">版本:PHP</td><br> <td nowrap align="center">板主:<a href="xiaocuimailto:cqcjg@163.net">xiaocui</a></td><br> <td nowrap align="center"><a href="bbspoint.php" target=input>积分查询</a></td><br> <td nowrap align="center"><br> <span class="smallFont"><span class="titleFont">帖子分页</span> <br> <?<br> if ($pageno>1)<br> {<br> echo "<a href=bbsshow.php?pageno=1>首页</a>";<br> echo "<a href=bbsshow.php?pageno=".($pageno-1)."> 前页</a>"; <br> }else<br> {<br> echo "<font color=darkgray>首页 前页</font>";<br> }<br> if ($pageno*$pagesize >= $recordcount )<br> {<br> echo "<font color=darkgray> 后页 尾页</font>";<br> }else<br> {<br> echo "<a href=bbsshow.php?pageno=".($pageno+1)."> 后页</a>";<br> echo "<a href=bbsshow.php?pageno=".$count."> 尾页</a>";<br> }<br> ?><br> 页次:<strong><? echo $pageno ?></strong>/<strong><? echo $count ?></strong>页</td><br> <td valign="baseline" align="center" nowrap><br> <form method="POST" action="bbsshow.php" onsubmit="return formcheck()" name="showform"><br> <p><span class="smallFont">转到:<br> <input type="text" name="pageno" size="5" maxlength="10" class="smallInput" value="1">页<br> <input class="buttonface" type="submit" value=" Go " name="gotosubmit"></span></p><br> </td></form><br> </tr><br> </table><br> <ul><br> <? <br> for($num=1;$num<=$pagesize;$num++)<br> {<br> if(odbc_fetch_row($Result_ID,($num+($pageno-1)*$pagesize))>=1) <br> {<br> $showlen = strlen(odbc_result($Result_ID,content));<br> echo "<li><image src=images/icon".odbc_result($Result_ID,messagetype).".gif> ";<br> echo "<a href=bbsrepeat.php?ID=".odbc_result($Result_ID,ID)." target=input>".odbc_result($Result_ID,subject)." ";<br> if($showlen < 1)<br> { <br> echo "<无内容> ";<br> }<br> <br> echo "</a>【<b>".odbc_result($Result_ID,name)."</b>】 <i>".odbc_result($Result_ID,date_time);<br> echo "</i> [ID:".odbc_result($Result_ID,ID)." 点击:".odbc_result($Result_ID,hitnum);<br> echo "] (".$showlen." bytes) <font color=red>(".odbc_result($Result_ID,childnum).")</font>";<br> if (substr(odbc_result($Result_ID,date_time),0,10)==substr(date("Y-m-d"),0,10)) <br> {<br> echo " <img width=30 height=15 src=images/new2.gif>";<br> }<br> echo "</li><br>";<br> <br> if(odbc_result($Result_ID,childnum) <> 0 )<br> {<br> echo "<ul>";<br> $layernum = $layernum + 1;<br> $strQuery = "SELECT * FROM bbsmessage Where parentID=".odbc_result($Result_ID,ID);<br> $child_ID[$layernum]=odbc_exec($Connection_ID,$strQuery);<br> showstr();<br> $layernum = $layernum - 1;<br> echo "</ul>"; <br> } <br> }<br> }<br> <br> ?><br> </ul><br> <br><br> <?<br> }<br> odbc_free_result($Result_ID);<br> odbc_close($Connection_ID);<br> ?><br> </body> <br> </html>
一个论坛的例子(部分)<br> |