zoukankan      html  css  js  c++  java
  • 贴吧小项目2

    建表:帖子表和回复表

    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="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; 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;*/
        1000px;
        border:1px solid green;
    }
    
    /*帖子*/
    .tiezi{
        1000px;
        border:1px solid green;
        position: relative;
        height:80px;
    }
    .replynum{
        position: absolute;
        top:10px;
        left:20px;
        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;
        500px;
    
    }
    .content{
        font-size: 17px;
        position: absolute;
        top:40px;
        left:80px;
        500px;
    
    }
    .info{
        position: absolute;
        left:600px;
        60px;
        height:60px;
    }
    .info li a{
        font-size: 12px;
        margin-top: 5px;
    
    }
    
  • 相关阅读:
    Python解析Yahoo的XML格式的天气预报数据
    如何卸载wineQQ?
    纪念我的第一篇
    hihocoder1062 最近公共祖先·一
    hihocoder1055 刷油漆(树形DP)
    hihocoder1050 树中的最长路径
    hihocoder1049 根据二叉树的先序序列和中序序列求后序序列
    hihocoder1044 状态压缩
    hihocoder1043 完全背包
    hihocoder1038 01背包
  • 原文地址:https://www.cnblogs.com/lzzhuany/p/4739838.html
Copyright © 2011-2022 走看看