如何用php设计此题!!!!!

2013 年 5 月 10 日3990

<!--main主体start-->
<div id="main">
<!--大边框-->
<?php
include "../conf/config.php";
include "../conf/conn.php";
$pages = $_GET['page'];
$id = $_GET['postid'];
$_SESSION['postid'] = $id;
$sql = "select cid,title,content,uid,ptime,pip,count from ".DB_PREFIX."post where id=".$id;
$result = mysql_query($sql);
if($result && mysql_num_rows($result)){
while($row = mysql_fetch_assoc($result)){
?>
<?php
if($pages == 1 || empty($pages)){
?>
<div class="post">
<div class="xiangqing_top">
<div class="zuo">回复:

<?php
$sql = "select count(pid) from ".DB_PREFIX."reply where pid=".$id;
$resultts = mysql_query($sql);
if($resultts && mysql_num_rows($resultts)){
$rew = mysql_fetch_assoc($resultts);
echo $rew['count(pid)'];
}
?>

|查看:<?php echo $row['count']?></div>
<div class="you"><?php echo $row['title']; ?>
<div class="louzhu"><font color="red">楼主</font></div>
</div>

</div>
<div class="xiangqing_middle">
<div class="zuo">
<?php
$sql = "select username,rtime,password,rip,qxid from ".DB_PREFIX."user where id=".$row[uid];
$res = mysql_query($sql);
if($res && mysql_num_rows($res)){
while($ro = mysql_fetch_assoc($res)){
echo $ro['username'];
?>

</div>
<div class="you"><?php echo "发布于:".date("Y-m-d H:i:s",$row['ptime']);?>

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
<?php
if($_SESSION['username']==$ro['username']){
echo "<a href='fatie4.php?id=".$id."'>编辑</a>";
}
?>
</div>
</div>
<div class="xiangqing_bottom">
<div class="left">
<?php
$sql = "select age,sex,edu,signed,pic,t_name,telephone,qq,email from ".DB_PREFIX."user_detail where uid=".$row[uid];
$re = mysql_query($sql);
if($re && mysql_num_rows($res)){
while($r = mysql_fetch_assoc($re)){
?>
<div class="tu">
<?php if(empty($r['pic']) || $r['pic']==null){
echo "<img src='../public/images/a_huang_small.gif'>";
}else{
echo "<img src='../public/images/".$r['pic']."_huang_small.gif'>";
}
?>
</div>
<div class="zi">
<ul>
<li>UID:<?php echo $row['uid']; ?></li>
<li>NAME:
<?php
echo $r['t_name'];
?>
</li>
<li>age:<?php echo $r['age']; ?></li>
<li><?php
if($ro['qxid']==2){
if((time()-$ro['rtime'])<300){
echo "新手上路";
}else{
echo "普通会员";
}
}elseif($ro['qxid']==5){
echo "<font color='blue'>管理员</font>";
}elseif($ro['qxid']==10){
echo "<font color='red'>超级管理员</font>";
}
?>
</li>
</ul>
</div>
</div>

<div class="right"><?php echo $row['content']; ?></div>
</div>
</div>
<?php
}
}
?>
<?php
}
}
?>

<?php
}
}
}
?>
<?php

//设置每页显示的条数
$page_size = PAGE_SIZE1;
//计算记录总数
$sql = "select count(*) as c from ".DB_PREFIX."reply where pid=".$id;

$resultc = mysql_query($sql);

$count = mysql_result($resultc,0);

//计算总页数
$page_count = ceil($count/$page_size);

$page_num = !empty($_GET['page'])?$_GET['page']:1;

$limit = " limit ".(($page_num-1)*$page_size).",".$page_size;

?>

<?php
$sql = "select id,uid,content,ptime,pip,qxid from ".DB_PREFIX."reply where pid=".$id." order by ptime".$limit;
$resultr = mysql_query($sql);
if($resultr && mysql_num_rows($resultr)){
$i = 1;
while($rowr = mysql_fetch_assoc($resultr)){

?>
<div>
<div class="xiangqing_middle">
<div class="zuo">
<?php
$sql = "select username,rtime,password,rip,qxid from ".DB_PREFIX."user where id=".$rowr[uid];
$resr = mysql_query($sql);
if($resr && mysql_num_rows($resr)){
while($ror = mysql_fetch_assoc($resr)){
echo $ror['username'];
?>

</div>
<div class="you">发表于:<?php echo date("Y-m-d H:i:s",$rowr['ptime'])?>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
<!---------------悲剧的div死活上不去啊!!!只能这样折中了-------------------->
<?php
if($pages == 1 || empty($pages)){
if($i==1){
echo "楼顶";
}elseif($i==2){
echo "吊扇";
}elseif($i==3){
echo "拖鞋";
}elseif($i==4){
echo "地板";
}elseif($i==5){
echo "地下室";
}else{
echo $i."楼";
}
}else{
echo (($pages-1)*8+$i)."楼";
}
?>
</div>

</div>
<div class="xiangqing_bottom">
<?php
$sql = "select t_name,age,sex,edu,signed,pic,qq,telephone from ".DB_PREFIX."user_detail where uid=".$rowr[uid];
$resd = mysql_query($sql);
if($resd && mysql_num_rows($resd)){
while($rod = mysql_fetch_assoc($resd)){
?>

<div class="left">
<div class="tu">

<?php if(empty($rod['pic']) || $rod['pic']==null){
echo "<img src='../public/images/a_huang_small.gif'>";
}else{
echo "<img src='../public/images/".$rod['pic']."_huang_small.gif'>";
}
?>

</div>
<div class="zi">
<ul>

<li>UID:<?php echo $rowr['uid'];?></li>
<li>NAME:<?php echo $rod['t_name'];?></li>
<li>AGE:<?php echo $rod['age'] ?></li>
<li>
<?php
if($ror['qxid']==2){
if((time()-$ror['rtime'])<300){
echo "新手上路";
}else{
echo "普通会员";
}
}elseif($ror['qxid']==5){
echo "<font color='blue'>管理员</font>";
}elseif($ror['qxid']==10){
echo "<font color='red'>超级管理员</font>";
}
?>

</li>
</ul>
</div>
</div>

<div class="right"><?php
if($rowr['qxid']==1){
echo $rowr['content'];
}else{
echo "<font color='red'>该帖子内容已经被管理员屏蔽!!!!!!如有疑问请联系管理员</font>";
}

?>

</div>
</div>
</div>
<?php
}
}
?>
<?php
}
}
?>
<?php
$i++;
}

}

?>
<div class="xiangqing_top">
<?php
//这里你加一个if语句 判断你们要求的那个条件 如果成立则可以输出页脚
echo "
<a href='?postid=".$_SESSION['postid']."&page=1'>首页</a>
<a href='?postid=".$_SESSION['postid']."&page=".((($page_num-1)<1)?1:($page_num-1)).$where_link."'>上一页</a>
<a href='?postid=".$_SESSION['postid']."&page=".((($page_num+1)>$page_count)?$page_count:($page_num+1)).$where_link."'>下一页</a>
<a href='?postid=".$_SESSION['postid']."&page=".$page_count.$where_link."'>尾页</a>
<font color='red'><b>";
if($page_count==0){
echo 1;
}else{
echo $page_count;
}
echo "</b></font>/<font color='red'><b>".$page_num."</b></font>";
?>

</div>

</div>
<!--main主体end-->

0 0