亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

メッセージを表示する PHP 開発掲示板チュートリアル

次のコードを見(jiàn)てください:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>留言板</title>
   <style type="text/css">
        *{margin:0px;padding:0px;}
        body{background:#eee;}
        #bdy{width:414px;height:736px;margin:0 auto;margin-top:20px;
            background:#66CDAA;
        }
        #top{font-family:"隸書";font-size:30px;text-align:center;/*margin-top:18px;*/
            color:#f60;}
        .a{text-decoration:none;color:#fff;float:right;padding-right:15px;}
        .a:hover{color:red;}
        #cont{width:414px;height:736px;margin:0 auto;margin-top:20px;}
        #left{width:350px;height:300px;margin-top:80px;margin-left:15px;/*float:left;*/
            background:#48D1CC;padding-left:5px;}

        #right{width:360px;height:200px;margin-top:20px;background:#48D1CC;
            margin-left:15px;/*float:left;*/}
        h5{text-align:center;margin-top:15px;margin-bottom:20px;}
        #sub{width:120px;height:25px;margin-top:15px;}
        #sub:hover{background:#AFEEEE;}
        .span{font-size:18px;color:red;font-weight:bold;}
        table{width:360px;margin:0 auto;margin-top:15px;border:1px solid #eee;}
        td{text-align:center;}
        #td a{text-decoration:none;color:#eee;}
        #td a:hover{color:red;}
    </style>
</head>
<body>
    <div id="bdy">
        <div id="top">留言板</div>
        <a href="login.php" class="a">登錄</a>
        <a href="reg.php" class="a">注冊(cè)</a>
        <div id="cont">
            <div id="left">
                <h5>寫留言</h5>
                <form method="post" action="addmessage.php">
                    標(biāo)題:<input type="text" placeholder="請(qǐng)輸入標(biāo)題" name="title">
                    </br></br>
                    內(nèi)容:<textarea cols="40" rows="5" name="content"></textarea>
                    </br></br>
                    <input type="submit" value="添加留言" id="sub">
                </form>
            </div>
            <div id="right"></div>
        </div>
    </div>
</body>
</html>

ここでは <div id="right"></div> を書きました。

このタグにはコンテンツを追加していません。ここにメッセージが表示されます。

レットは、次のコードを見(jiàn)てください&lt; div id = "right"&gt; id&lt;/th&gt; 「TD」&gt; ;/table>

</div>

テーブルを使って、表示內(nèi)容を書いていきます

ファイルの先頭にphpタグを追加します

コードは次のとおりです:

<?php
    session_start();
    require_once('conn.php');//鏈接數(shù)據(jù)庫(kù)

    //分頁(yè)
    $page=isset($_GET['page']) ?$_GET['page'] :1 ;//接收頁(yè)碼
    $page=!empty($page) ? $page :1;
    
    $table_name="mess";//查取表名設(shè)置
    $perpage=5;//每頁(yè)顯示的數(shù)據(jù)個(gè)數(shù)

    //最大頁(yè)數(shù)和總記錄數(shù)
    $total_sql="select count(*) from $table_name";
    $total_result =mysql_query($total_sql);
    $total_row=mysql_fetch_row($total_result);
    $total = $total_row[0];//獲取最大頁(yè)碼數(shù)
    $total_page = ceil($total/$perpage);//向上整數(shù)
    //臨界點(diǎn)
    $page=$page>$total_page ? $total_page:$page;//當(dāng)下一頁(yè)數(shù)大于最大頁(yè)數(shù)時(shí)的情況
    //分頁(yè)設(shè)置初始化
    $start=($page-1)*$perpage;

    //展示留言
    $sql1 = "select * from mess order by id desc limit $start,$perpage";
    $res = mysql_query($sql1);
    //$row=mysql_fetch_array($res);
    
?>

次に、 HTMLページPHPコードも追加します。;
'];?>,こんにちは! &lt;/span&gt;
ref = "reg .php" class = "a"&gt; register&lt;/a&gt;
"&gt; ;
;
<div id="right">
<table cellpacing="0" cellpadding="0" border="1">
<tr>
<th>ID</th>
< ;th>標(biāo)題</th>
<th>內(nèi)容</th>
<th>発言者</th> ;
</tr>
<?php
while($row = mysql_fetch_array ($res)){
?>
<tr>
<td><?php echo $ row['id'];?></td>
<td><?php echo $row['title'];?</td>
<td<?php echo $row['content'];?></td>
<td>< ?php echo $_SESSION['name'];?></td>
</tr>
?? ??? ??? ??? ??? ??? ?<?php
}
?>

<tdcolspan="4" id="td">
<a href="<?php echo "$_SERVER[PHP_SELF]? page=1"?>">首頁(yè)</a>
<a href="<?php echo "$_SERVER[PHP_SELF]?page=".($page-1)?>"> ;上一頁(yè)</a>
<a href="<?php echo "$_SERVER[PHP_SELF]?page=".($page+1)?>">下一頁(yè)</ a>
<a href="<?php echo "$_SERVER[PHP_SELF]?page={$total_page}"?>">末頁(yè)</a>?

</tr>
</table> </div>
</div>

下面是完整代碼:

<?php
    session_start();
    require_once('conn.php');//鏈接數(shù)據(jù)庫(kù)

    //分頁(yè)
    $page=isset($_GET['page']) ?$_GET['page'] :1 ;//接收頁(yè)碼
    $page=!empty($page) ? $page :1;
    
    $table_name="mess";//查取表名設(shè)置
    $perpage=5;//每頁(yè)顯示的數(shù)據(jù)個(gè)數(shù)

    //最大頁(yè)數(shù)和總記錄數(shù)
    $total_sql="select count(*) from $table_name";
    $total_result =mysql_query($total_sql);
    $total_row=mysql_fetch_row($total_result);
    $total = $total_row[0];//獲取最大頁(yè)碼數(shù)
    $total_page = ceil($total/$perpage);//向上整數(shù)
    //臨界點(diǎn)
    $page=$page>$total_page ? $total_page:$page;//當(dāng)下一頁(yè)數(shù)大于最大頁(yè)數(shù)時(shí)的情況
    //分頁(yè)設(shè)置初始化
    $start=($page-1)*$perpage;

    //展示留言
    $sql1 = "select * from mess order by id desc limit $start,$perpage";
    $res = mysql_query($sql1);
    //$row=mysql_fetch_array($res);
    
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>留言板</title>
   <style type="text/css">
        *{margin:0px;padding:0px;}
        body{background:#eee;}
        #bdy{width:414px;height:736px;margin:0 auto;margin-top:20px;
            background:#66CDAA;
        }
        #top{font-family:"隸書";font-size:30px;text-align:center;/*margin-top:18px;*/
            color:#f60;}
        .a{text-decoration:none;color:#fff;float:right;padding-right:15px;}
        .a:hover{color:red;}
        #cont{width:414px;height:736px;margin:0 auto;margin-top:20px;}
        #left{width:350px;height:300px;margin-top:80px;margin-left:15px;/*float:left;*/
            background:#48D1CC;padding-left:5px;}

        #right{width:360px;height:200px;margin-top:20px;background:#48D1CC;
            margin-left:15px;/*float:left;*/}
        h5{text-align:center;margin-top:15px;margin-bottom:20px;}
        #sub{width:120px;height:25px;margin-top:15px;}
        #sub:hover{background:#AFEEEE;}
        .span{font-size:18px;color:red;font-weight:bold;}
        table{width:360px;margin:0 auto;margin-top:15px;border:1px solid #eee;}
        td{text-align:center;}
        #td a{text-decoration:none;color:#eee;}
        #td a:hover{color:red;}
    </style>
</head>
<body>
    <div id="bdy">
        <div id="top">留言板</div>
        <?php
            if(!empty($_SESSION['name'])){
        ?>
        <span class="span">尊敬的用戶:<?php echo $_SESSION['name'];?>,您好!</span>
        <?php
            }else{
        ?>
        <a href="login.php" class="a">登錄</a>
        <a href="reg.php" class="a">注冊(cè)</a>
        <?php
            }
        ?>
        <div id="cont">
            <div id="left">
                <h5>寫留言</h5>
                <form method="post" action="addmessage.php">
                    標(biāo)題:<input type="text" placeholder="請(qǐng)輸入標(biāo)題" name="title">
                    </br></br>
                    內(nèi)容:<textarea cols="40" rows="5" name="content"></textarea>
                    </br></br>
                    <input type="submit" value="添加留言" id="sub">
                </form>
            </div>
            <div id="right">
                    <table cellspacing="0" cellpadding="0" border="1">
                        <tr>
                            <th>ID</th>
                            <th>標(biāo)題</th>
                            <th>內(nèi)容</th>
                            <th>留言者</th>
                        </tr>
                        <?php
                            while($row = mysql_fetch_array($res)){
                        ?>
                        <tr>
                            <td><?php echo $row['id'];?></td>
                            <td><?php echo $row['title'];?></td>
                            <td><?php echo $row['content'];?></td>
                            <td><?php echo $_SESSION['name'];?></td>
                        </tr>
                        <?php
                            }
                        ?>
                        <tr>
                            <td colspan="4" id="td">
                                <a href="<?php echo "$_SERVER[PHP_SELF]?page=1"?>">首頁(yè)</a>
                                   <a href="<?php echo "$_SERVER[PHP_SELF]?page=".($page-1)?>">上一頁(yè)</a>
                                <a href="<?php echo "$_SERVER[PHP_SELF]?page=".($page+1)?>">下一頁(yè)</a>
                                <a href="<?php echo "$_SERVER[PHP_SELF]?page={$total_page}"?>">末頁(yè)</a>            
                               </td>
                          </tr>
                    </table>
            </div>
        </div>
    </div>
</body>
</html>


學(xué)び続ける
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>留言板</title> <style type="text/css"> *{margin:0px;padding:0px;} body{background:#eee;} #bdy{width:414px;height:736px;margin:0 auto;margin-top:20px; background:#66CDAA; } #top{font-family:"隸書";font-size:30px;text-align:center;/*margin-top:18px;*/ color:#f60;} .a{text-decoration:none;color:#fff;float:right;padding-right:15px;} .a:hover{color:red;} #cont{width:414px;height:736px;margin:0 auto;margin-top:20px;} #left{width:350px;height:300px;margin-top:80px;margin-left:15px;/*float:left;*/ background:#48D1CC;padding-left:5px;} #right{width:360px;height:200px;margin-top:20px;background:#48D1CC; margin-left:15px;/*float:left;*/} h5{text-align:center;margin-top:15px;margin-bottom:20px;} #sub{width:120px;height:25px;margin-top:15px;} #sub:hover{background:#AFEEEE;} .span{font-size:18px;color:red;font-weight:bold;} table{width:360px;margin:0 auto;margin-top:15px;border:1px solid #eee;} td{text-align:center;} #td a{text-decoration:none;color:#eee;} #td a:hover{color:red;} </style> </head> <body> <div id="bdy"> <div id="top">留言板</div> <a href="login.php" class="a">登錄</a> <a href="reg.php" class="a">注冊(cè)</a> <div id="cont"> <div id="left"> <h5>寫留言</h5> <form method="post" action="addmessage.php"> 標(biāo)題:<input type="text" placeholder="請(qǐng)輸入標(biāo)題" name="title"> </br></br> 內(nèi)容:<textarea cols="40" rows="5" name="content"></textarea> </br></br> <input type="submit" value="添加留言" id="sub"> </form> </div> <div id="right"> <table cellspacing="0" cellpadding="0" border="1"> <tr> <th>ID</th> <th>標(biāo)題</th> <th>內(nèi)容</th> <th>留言者</th> </tr> <tr> <td>1</td> <td>明天過(guò)后</td> <td>11111</td> <td>張飛</td> </tr> <tr> <td colspan="4" id="td"> <a href="">首頁(yè)</a> <a href="">上一頁(yè)</a> <a href="">下一頁(yè)</a> <a href="">末頁(yè)</a> </tr> </table> </div> </div> </div> </body> </html>
提出するリセットコード
  • おすすめコース
  • コースウェアのダウンロード
現(xiàn)時(shí)點(diǎn)ではコースウェアはダウンロードできません?,F(xiàn)在スタッフが整理中です。今後もこのコースにもっと注目してください?