Page d'accueil du didacticiel du site Web d'entreprise de développement PHP
Dans le chapitre précédent, nous avons déjà parlé de la page qui affiche la liste
Les informations de la base de données sont affichées sur le front-end, ce qui est similaire à celui ci-dessus. Regardons le code de la page d'accueil. :
<?php require_once('../admin/conn.php'); $sql ="SELECT * from product order by id desc limit 0,4"; $res = mysql_query($sql); $sql1 = "SELECT * from news where type = 1 limit 0,5"; $res1 = mysql_query($sql1); ?> <!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>首頁</title> </head> <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;} /*首頁內(nèi)容部分樣式*/ .dv{width:410px;border:1px solid #ccc;margin:0 auto;margin-top:30px;} .dv1{width:90px;height:50px;margin:0 auto;line-height:50px;background:#f0f0f0; text-align:center;margin-top:-28px;font-weight:bold;} .content{width:410px;text-align:center;font-size:12px;margin:0 auto;line-height:25px;} .product{width:410px;height:130px;margin:0 auto;} .product_1{width:80px;height:80px;float:left;margin-left:5px;margin-top:18px;padding-left:12px;} .info{width:410px;height:250px;background:#eee;margin:0 auto;} .info_left{width:200px;border-right:1px dashed #ccc;} .info_left h3{padding-top:15px;margin-left:15px;} /*.info_left p{padding-left:15px;margin-top:8px;text-indent:2em;line-height:25px;float:left;}*/ .info_right{width:200px;float:right;} .info_right h3{padding-top:15px;margin-left:15px;} .info_right div{padding-left:15px;margin-top:8px;padding-top:10px;} .info_right span{float:right;margin-right:15px;} /*底部樣式*/ .but{width:410px;height:60px;margin:0 auto;text-align:center;background:#999; padding-top:8px;margin-top:5px;} </style> <body> <div class="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="https://img.php.cn/upload/course/000/000/010/582407c034cfe355.jpg" width="50" height="50"></div> </div> <div id="cnt"> <img src="https://img.php.cn/upload/course/000/000/010/5824078a8353f806.jpg" width="410px" height="100"> </div> <div class="dv"></div> <div class="dv1">產(chǎn)品展示</div> <div class="content"> 核心團隊長期在中國科學院、航天部工作,具有豐厚的環(huán)保、太陽能、真空電子束、機械制造等專業(yè)技術(shù)研發(fā)和實際工程經(jīng)驗積累,系本領(lǐng)域 資深高級專家。主要業(yè)務(wù)處于國內(nèi)領(lǐng)先、國際先進水平 </div> <div class="product"> <?php while ($row = mysql_fetch_array($res)){ ?> <div class="product_1"> <a href="#"><img src="../uploads/<?php echo $row['imgname'];?>" width="80" height="90"></a> </div> <?php } ?> </div> <div class="info"> <div class="info_right"> <h3>新聞資訊</h3> <?php while($row1 = mysql_fetch_array($res1)){ ?> <div><?php echo $row1['title'];?> <span><?php echo date('y-m-d',$row1['newtime']);?></span></div> <?php } ?> </div> <div class="info_left"> <h3>公司簡介</h3> <p>核心團隊長期在中國科學院、航天部工作,具有豐厚的環(huán)保、太陽能、真空電子束、機械制造等專業(yè)技術(shù)研發(fā)和實際工程經(jīng)驗積累,系本領(lǐng)域資深高級專家。主要業(yè)務(wù)處于國內(nèi)領(lǐng)先、國際先進水平</p> </div> </div> <div class="but">地址:安徽省合肥市科學大道669號(黃山路與科學大道交口東南角) 預約電話:400-800-9558 備ICP 皖0219845號 <p>版權(quán)所有:合肥環(huán)??萍?nbsp;All rights reserved</p> </div> </div> </body> </html>