码迷,mamicode.com
首页 > 其他好文 > 详细

贴吧小项目2

时间:2015-08-18 18:31:43      阅读:99      评论:0      收藏:0      [点我收藏+]

标签:

建表:帖子表和回复表

create table thread(
tid int not null auto_increment primary key,
username varchar(20) not null default ‘‘,
title varchar(40) not null default ‘‘,
content text not null,
pubtime int 
)engine myisam charset utf8;

create table reply(
rid int not null auto_increment primary key,
tid int not null,
username varchar(20) not null default ‘‘,
content text not null,
reptime int 
)engine myisam charset utf8;

 贴吧首页

<?php

require("./include/init.php");
$sql="select tid,username,title,content,pubtime,(select count(*) from reply where reply.tid=thread.tid) as num from thread order by pubtime desc";
$list=getAll($sql,$conn);

?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自由发帖</title>
<link rel="stylesheet" type="text/css" href="./ind.css">
</head>
<body>
    <div id="top">
        <ul>
            <li><a href="index.php">回到贴吧首页</a></li>
            <!-- <li><a href="#">22222</a></li>
            <li><a href="#">3333</a></li>
            <li><a href="#">4444</a></li> -->
        </ul>
    </div>
    <?php foreach($list as $k=>$v){ ?>
    
    <div class="tiezi">
        <div class="tie">
            <i class="replynum"><?php echo $v["num"];?></i>
            <h3 class="title"><a href=<?php echo ‘chakan.php?tid=‘.$v[‘tid‘];?>><?php echo $v["title"];?></a></h3>
            <p class="content"><?php echo $v["content"];?></p>
            <div class="info"   style="width:100px;">
                <li><span>发送人:</span><a href="#"><?php echo $v["username"];?></a></li>
                <li><span>发送时间:</span><a href="#">
                <?php
                    $ling=date("Y-m-d");
                    $tmp=strtotime($ling);
                    if($v["pubtime"]>=$tmp){
                        echo date("H:i",$v["pubtime"]);
                    }else{
                        echo date("m-d",$v["pubtime"]);
                    }
                 ?>
                </a></li>
            </div>

        </div>
        
    </div>
    <?php }?>
    <div style="margin:0 auto; border:1px solid green; width:1000px">
        <form action="cunchu.php" method="post">
            用户名:<input type="text" name="username"/><br/>
            标题:<input type="text" name="title"/><br/>
            内容:<textarea cols="30" rows="6" name="content"></textarea><br/>
            <input type="submit" value="发送" />
        </form>
    </div>
</body>
</html>

 css文件

*{
    margin:0 auto;
    padding: 0;
}
li{
    list-style: none;
}
ul{
    height:30px;
}
ul li{
    list-style: none;
    float: left;
    margin-left: 30px;
    border-right:1px solid gray;
}
a{
    text-decoration: none;
}
a:hover{
    text-decoration: block;
}
.tie{

}
#top{
    margin-top: 80px;
    /*background: blue;*/
    width:1000px;
    border:1px solid green;
}

/*帖子*/
.tiezi{
    width:1000px;
    border:1px solid green;
    position: relative;
    height:80px;
}
.replynum{
    position: absolute;
    top:10px;
    left:20px;
    width:40px;
    height:30px;
    background: #F7F7F7;
    padding:2px 3px 2px 5px;
    font-size: 17px;
}
.title{
    position: absolute;
    top:10px;
    left:80px;
    font-size: 25px;
    color: #2D64B3;
    width:500px;

}
.content{
    font-size: 17px;
    position: absolute;
    top:40px;
    left:80px;
    width:500px;

}
.info{
    position: absolute;
    left:600px;
    width:60px;
    height:60px;
}
.info li a{
    font-size: 12px;
    margin-top: 5px;

}

 

贴吧小项目2

标签:

原文地址:http://www.cnblogs.com/lzzhuany/p/4739838.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!