php综合练习--mymessbox--user说说

<?php 
    $conn = mysql_connect("localhost", "root", "111");
    mysql_select_db("mymessbox", $conn);
    mysql_query("set names utf8");

    function sub_title($title){
            $len = 22;
            return mb_strlen($title, ‘utf-8‘)<=$len ? $title : (mb_substr($title,0,$len,‘utf-8‘)."...");
    }

    $totsql = "select count(*) from say";
        $totret = mysql_query($totsql);
    $totrow = mysql_fetch_row($totret);

    $length = 20;

    $totnum = ceil($totrow[0] / $length);

    $pagenum = @$_GET[‘page‘] ? $_GET[‘page‘] : 1;
    if ($pagenum > $totnum) {
        $pagenum = $totnum;
    }
    $offset = ($pagenum - 1 ) * $length;

    $sql1 = "select * from say order by id desc limit {$offset},{$length}";
    $ret1 = mysql_query($sql1);
?>

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>say</title>
    <style>
        body {
            margin:0px;
            padding:0px;
            font-family: ‘宋体‘, Simsun;
        }
        a {
            text-decoration: none;
            font-size: 18px;
            font-weight: bold;    
        }
        a:hover {
            position: relative;
            top: 1px;
            left: 1px;
        }
        #wrap {
            width: 700px;
            margin: 0 auto;
        }
        #header {
            width: 100%;
            height: 60px;
            background: #ccc;
            font-size: 30px;
            font-family: Comic Sans MS;
            line-height: 60px;
            text-align: center;
        }
        .nav {
            margin: 0 auto;
            width: 100%;
            height: 5px;
            clear:both;
        }
        #menu {
            width: 100%;
            height: 30px;
            background: #ccc;
            line-height: 30px;
        }
        .mu {
            width: 50px;
            padding-left: 104px;
        }
        #content {
            width: 100%;
            margin: 0 auto;
            background: #ccc;
        }
        #page {
            width: 100%;
            text-align: center;
            clear: both;
            padding-top: 10px;
        }
        #footer {
            width: 100%;
            height: 50px;
            background: #ccc;
            line-height: 50px;
            text-align: center;
        }
        #footer a{
            font-size: 10px;
            font-weight: bold;
        }
        .say {
            width:100%;
            margin: 0px auto;
            font-family: "宋体",Simsun;
            font-weight: bold;
            padding-top: 12px;
        }
        #title {
            margin-left: 130px;

        }
        #title a {
            text-decoration: none;
            font-size: 18px;
            font-weight: bold;
            padding-left: 0px;
        }
        #title a:visited {
            color: red;
        }
    </style>

</head>
<body>
    <div id="wrap">
        <div id="header">My Zone</div>
        <div class="nav"></div>
        <div id="menu">
            <span class="mu">
                <a href=‘index.php‘>主页</a>
            </span>
            <span class="mu">
                <a href=‘‘>相册</a>
            </span>
            <span class="mu">
                <a href=‘say.php‘>说说</a>
            </span>
            <span class="mu">
                <a href=‘mess.php‘>留言</a>
            </span>
        </div>
        <div class="nav"></div>
        <div id="content">
        <?php
            while ($row1 = mysql_fetch_assoc($ret1)) {
        ?>    
            <div class="say">
                <span id="title"><a href="content.php?id=<?php echo $row1[‘id‘]?>"><?php echo sub_title($row1[‘title‘]);?></a></span>
            </div>
        <?php
            }
                $prevpage = $pagenum - 1;
                $nextpage = $pagenum + 1;

            echo "
                <div id=‘page‘>
                <a href=‘say.php?page=$prevpage‘>上一页</a>|<a href=‘say.php?page=$nextpage‘>下一页</a>
                </div>";
         ?>
         </div>
         <div class="nav"></div>
        <div id="footer">
            <a href="http://www.baidu.com">百度一下</a>|<a href="https://www.google.com/hk">google</a>
        </div>
    </div>
</body>
</html>
say.php

点击标题,内容显示还没有做出来,还有对内容的评论。

php综合练习--mymessbox--user说说,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。