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

Product display of PHP development corporate website tutorial

In the above sections, we have taken out the database information, then called it on the front end, and displayed it

Let’s see how the product is displayed. The code is as follows:

<?php
    require_once('../admin/conn.php');
    $page=isset($_GET['page']) ?$_GET['page'] :1 ;//接收頁碼
    $page=!empty($page) ? $page :1;
    $table_name="product";//查取表名設(shè)置
    $perpage=9;//每頁顯示的數(shù)據(jù)個(gè)數(shù)
    //最大頁數(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];//獲取最大頁碼數(shù)
    $total_page = ceil($total/$perpage);//向上整數(shù)
    //臨界點(diǎn)
    $page=$page>$total_page ? $total_page:$page;//當(dāng)下一頁數(shù)大于最大頁數(shù)時(shí)的情況
    //分頁設(shè)置初始化
    $start=($page-1)*$perpage;
    $sql = "SELECT * from product order by id desc limit $start,$perpage";
    $res = mysql_query($sql);
    // $sql="select * from product order by id desc limit 1,9";
    // $res = mysql_query($sql);
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> 
    <meta name="format-detection" content="telephone=no">
    <title>產(chǎn)品展示</title>
    <style type="text/css">
        *{margin:0px;padding:0px;}
        /*頭部樣式*/
        #top{width:410px;height:40px;margin:0 auto;}
        body{background:#f0f0f0;}
        #to_left{float:left;}
        #top_right{float:right;margin-top:20px;margin-right:15px;}
        li{float:left;list-style:none;margin:0px 5px; padding-bottom:15px;}
        li a{text-decoration:none;color:#000;}
        li a:hover{color:red;}
        #cnt{width:410px;margin:0 auto;}
        /*產(chǎn)品展示部分樣式*/
        .product_c{width:410px;height:500px;margin:0 auto;background:#e0e0e0;}
        .product_top{margin-top:5px;margin-left:10px;font-weight:bold;padding-top:15px;}
        .product_cnt{width:410px;height:450px;margin-top:10px;margin-left:14px;}
        .pro{width:100px;height:90px;border:1px solid #fff;float:
            left;margin-left:19px;margin-top:30px;}
        .page{float:left;margin-top:30px;margin-left:95px;}
        /*底部樣式*/
        .but{width:410px;height:60px;margin:0 auto;text-align:center;background:#999;
            padding-top:8px;margin-top:5px;}
    </style>
</head>
<body>
    <div id="top">
        <div id="top_right">
            <ul>
                <li><a href="index.php">首頁</a></li>
                <li><a href="about.php">關(guān)于我們</a></li>
                <li><a href="news.php">新聞資訊</a></li>
                <li><a href="product.php">產(chǎn)品展示</a></li>
                <li><a href="contact.php">聯(lián)系我們</a></li>
            </ul>
        </div>
        <div id="top_left"><img src="logo.jpg" width="50" height="50"></div>
    </div>
    <div id="cnt">
        <img src="messter.jpg" width="410px" height="100">
    </div>
    <div class="product_c">
        <div class="product_top">當(dāng)前位置>>產(chǎn)品展示</div>
        <div class="product_cnt">
            <?php
                while($row = mysql_fetch_array($res)){
            ?>
            <div class="pro"><img src="../uploads/<?php echo $row['imgname'];?>" width="98" height="88"></div>
            <?php
                }
            ?>
            <div class="page">
                <a href="<?php echo "$_SERVER[PHP_SELF]?page=1"?>">首頁</a>
                <a href="<?php echo "$_SERVER[PHP_SELF]?page=".($page-1)?>">上一頁</a><a href="<?php echo "$_SERVER[PHP_SELF]?page=".($page+1)?>">下一頁</a>
                <a href="<?php echo "$_SERVER[PHP_SELF]?page={$total_page}"?>">末頁</a>
            </div>
        </div>
    </div>
    <div class="but">地址:安徽省合肥市科學(xué)大道669號(hào)(黃山路與科學(xué)大道交口東南角)                 預(yù)約電話:400-800-9558
                        備ICP 皖0219845號(hào) <p>版權(quán)所有:合肥環(huán)保科技 All rights reserved</p>
    </div>
</body>
</html>

With the above code, we have also completed a paging effect

Continuing Learning
||
<?php require_once('../admin/conn.php'); $page=isset($_GET['page']) ?$_GET['page'] :1 ;//接收頁碼 $page=!empty($page) ? $page :1; $table_name="product";//查取表名設(shè)置 $perpage=9;//每頁顯示的數(shù)據(jù)個(gè)數(shù) //最大頁數(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];//獲取最大頁碼數(shù) $total_page = ceil($total/$perpage);//向上整數(shù) //臨界點(diǎn) $page=$page>$total_page ? $total_page:$page;//當(dāng)下一頁數(shù)大于最大頁數(shù)時(shí)的情況 //分頁設(shè)置初始化 $start=($page-1)*$perpage; $sql = "SELECT * from product order by id desc limit $start,$perpage"; $res = mysql_query($sql); // $sql="select * from product order by id desc limit 1,9"; // $res = mysql_query($sql); ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="format-detection" content="telephone=no"> <title>產(chǎn)品展示</title> <style type="text/css"> *{margin:0px;padding:0px;} /*頭部樣式*/ #top{width:410px;height:40px;margin:0 auto;} body{background:#f0f0f0;} #to_left{float:left;} #top_right{float:right;margin-top:20px;margin-right:15px;} li{float:left;list-style:none;margin:0px 5px; padding-bottom:15px;} li a{text-decoration:none;color:#000;} li a:hover{color:red;} #cnt{width:410px;margin:0 auto;} /*產(chǎn)品展示部分樣式*/ .product_c{width:410px;height:500px;margin:0 auto;background:#e0e0e0;} .product_top{margin-top:5px;margin-left:10px;font-weight:bold;padding-top:15px;} .product_cnt{width:410px;height:450px;margin-top:10px;margin-left:14px;} .pro{width:100px;height:90px;border:1px solid #fff;float: left;margin-left:19px;margin-top:30px;} .page{float:left;margin-top:30px;margin-left:95px;} /*底部樣式*/ .but{width:410px;height:60px;margin:0 auto;text-align:center;background:#999; padding-top:8px;margin-top:5px;} </style> </head> <body> <div id="top"> <div id="top_right"> <ul> <li><a href="index.php">首頁</a></li> <li><a href="about.php">關(guān)于我們</a></li> <li><a href="news.php">新聞資訊</a></li> <li><a href="product.php">產(chǎn)品展示</a></li> <li><a href="contact.php">聯(lián)系我們</a></li> </ul> </div> <div id="top_left"><img src="logo.jpg" width="50" height="50"></div> </div> <div id="cnt"> <img src="messter.jpg" width="410px" height="100"> </div> <div class="product_c"> <div class="product_top">當(dāng)前位置>>產(chǎn)品展示</div> <div class="product_cnt"> <?php while($row = mysql_fetch_array($res)){ ?> <div class="pro"><img src="../uploads/<?php echo $row['imgname'];?>" width="98" height="88"></div> <?php } ?> <div class="page"> <a href="<?php echo "$_SERVER[PHP_SELF]?page=1"?>">首頁</a> <a href="<?php echo "$_SERVER[PHP_SELF]?page=".($page-1)?>">上一頁</a><a href="<?php echo "$_SERVER[PHP_SELF]?page=".($page+1)?>">下一頁</a> <a href="<?php echo "$_SERVER[PHP_SELF]?page={$total_page}"?>">末頁</a> </div> </div> </div> <div class="but">地址:安徽省合肥市科學(xué)大道669號(hào)(黃山路與科學(xué)大道交口東南角) 預(yù)約電話:400-800-9558 備ICP 皖0219845號(hào) <p>版權(quán)所有:合肥環(huán)??萍?All rights reserved</p> </div> </body> </html>
submitReset Code