文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>一个php论坛的例子(部分)

一个php论坛的例子(部分)

时间:2007-02-17  来源:PHP爱好者

一个论坛的例子(部分)<br>

<br>

关键词:PHP<br>

<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>&nbsp;";<br>

echo "<a href=bbsrepeat.php?ID=".odbc_result($child_ID[$layernum],ID)." target=input>".odbc_result($child_ID[$layernum],subject)."&nbsp;";<br>

if($showlen <1 )<br>

{ <br>

echo "<无内容>&nbsp;";<br>

}<br>

<br>

echo "</a>【<b>".odbc_result($child_ID[$layernum],name)."</b>】&nbsp;&nbsp;<i>".odbc_result($child_ID[$layernum],date_time);<br>

echo "</i>&nbsp;[ID:".odbc_result($child_ID[$layernum],ID)."&nbsp;点击:".odbc_result($child_ID[$layernum],hitnum);<br>

echo "]&nbsp;(".$showlen."&nbsp;bytes)&nbsp;<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 "&nbsp;<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="mailto:[email protected]">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).">&nbsp;前页</a>";   <br>

}else<br>

{<br>

echo "<font color=darkgray>首页 前页</font>";<br>

}<br>

if ($pageno*$pagesize >= $recordcount )<br>

{<br>

echo "<font color=darkgray>&nbsp;后页 尾页</font>";<br>

}else<br>

{<br>

echo "<a href=bbsshow.php?pageno=".($pageno+1).">&nbsp;后页</a>";<br>

echo "<a href=bbsshow.php?pageno=".$count.">&nbsp;尾页</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>&nbsp;";<br>

echo "<a href=bbsrepeat.php?ID=".odbc_result($Result_ID,ID)." target=input>".odbc_result($Result_ID,subject)."&nbsp;&nbsp;";<br>

if($showlen <1)<br>

{ <br>

echo "<无内容>&nbsp;&nbsp;";<br>

}<br>

<br>

echo "</a>【<b>".odbc_result($Result_ID,name)."</b>】&nbsp;&nbsp;<i>".odbc_result($Result_ID,date_time);<br>

echo "</i>&nbsp;[ID:".odbc_result($Result_ID,ID)."&nbsp;点击:".odbc_result($Result_ID,hitnum);<br>

echo "]&nbsp;(".$showlen."&nbsp;bytes)&nbsp;<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 "&nbsp;<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>
php爱好者站 http://www.phpfans.net c/vc/c++/java.
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载