PHP用switch語句設計網站首頁____PHP

來源:互聯網
上載者:User

一 PHP指令碼 index.php

<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>switch語句的應用</title><style type="text/css"><!--body {background-color: #F1EFEB;margin-left: 00px;margin-top: 0px;margin-right: 0px;margin-bottom: 0px;}.STYLE4 {color: #154049;font-size: 13px;}a:link {text-decoration: none;color: #0A323C;}a:visited {text-decoration: none;color: #006600;}a:hover {text-decoration: none;color: #000033;}a:active {text-decoration: none;color: #003366;}--></style></head><body><center><table width="850" height="80" border="0" cellpadding="0" cellspacing="0">  <tr>    <td width="333" height="50">&nbsp;</td>    <td width="90">&nbsp;</td>    <td width="71">&nbsp;</td>    <td width="74">&nbsp;</td>    <td width="73" align="right">&nbsp;</td>    <td width="75" class="STYLE4">返回首頁</td>    <td width="83" class="STYLE4">加入收藏</td>    <td width="51">&nbsp;</td>  </tr>  <tr>    <td height="30">&nbsp;</td>    <td align="center">&nbsp;</td>    <td align="center"><span class="STYLE4"><a href="index.php?lmbs=最新商品">&nbsp;最新商品</a></span></td>    <td align="center"><span class="STYLE4"><a href="index.php?lmbs=熱門商品">&nbsp;熱門商品</a></span></td>    <td align="center"><span class="STYLE4"><a href="index.php?lmbs=<?php echo urlencode("推薦商品");?>">推薦商品</a></span></td>    <td align="center"><span class="STYLE4"><a href="index.php?lmbs=<?php echo urlencode("特殊商品");?>">特殊商品</a></span></td>    <td align="center"><span class="STYLE4"></span></td>    <td>&nbsp;</td>  </tr></table><table width="850" border="0" cellpadding="0" cellspacing="0">  <tr>    <td width="196" height="520" align="center" valign="top"><table width="180" height="523" border="1" cellpadding="1" cellspacing="1" bordercolor="#FFFFFF" bgcolor="#F1F1F1">      <tr>        <td height="25" align="center" bgcolor="#FFFFFF"><span class="STYLE4">&nbsp;&nbsp;<a href="index.php?lmbs=最新商品">&nbsp;最新商品</a></span></td>      </tr>      <tr>        <td height="25" align="center" bgcolor="#FFFFFF"><span class="STYLE4">&nbsp;&nbsp;<a href="index.php?lmbs=熱門商品">&nbsp;熱門商品</a></span></td>      </tr>      <tr>        <td height="25" align="center" bgcolor="#FFFFFF"><span class="STYLE4">&nbsp;&nbsp;&nbsp;<a href="index.php?lmbs=<?php echo urlencode("推薦商品");?>">推薦商品</a></span></td>      </tr>      <tr>        <td height="25" align="center" bgcolor="#FFFFFF"><span class="STYLE4">&nbsp;&nbsp;&nbsp;<a href="index.php?lmbs=<?php echo urlencode("特殊商品");?>">特殊商品</a></span></td>      </tr>      <tr>        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>      </tr>      <tr>        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>      </tr>      <tr>        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>      </tr>      <tr>        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>      </tr>      <tr>        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>      </tr>      <tr>        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>      </tr>      <tr>        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>      </tr>      <tr>        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>      </tr>      <tr>        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>      </tr>      <tr>        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>      </tr>      <tr>        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>      </tr>      <tr>        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>      </tr>      <tr>        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>      </tr>      <tr>        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>      </tr>      <tr>        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>      </tr>      <tr>        <td height="25" bgcolor="#FFFFFF">&nbsp;</td>      </tr>    </table></td>    <td width="600" align="center" valign="top"><table width="595" border="0" cellspacing="0" cellpadding="0">      <tr>        <td align="center" bgcolor="#FFFFFF"><?php switch($_GET[lmbs]){case "最新商品":        include "index1.php";    break;case "熱門商品":        include "index2.php";    break;case "推薦商品":        include "index3.php";    break;case "特殊商品":        include "index4.php";    break;case "":        include "index4.php";    break;}?></td>      </tr>    </table></td>    <td width="54">&nbsp;</td>  </tr></table></center></body></html>
 
index1.php
<html> <head> <metahttp-equiv="Content-Type"content="text/html; charset=gb2312"> <title>無標題文檔</title> </head> <body> <imgsrc="images/bg6.jpg"width="508"height="543"> </body> </html> index2.php <html> <head> <metahttp-equiv="Content-Type"content="text/html; charset=gb2312"> <title>無標題文檔</title> </head> <body> <ahref="index.php?lmbs=新品上市"></a> <imgsrc="images/bg7.jpg"width="547"height="548"> </body> </html> index3.php <html> <head> <metahttp-equiv="Content-Type"content="text/html; charset=gb2312"> <title>無標題文檔</title> </head> <body> <a href="index.php?lmbs=<?php echo urlencode("特價區");?>"></a> <imgsrc="images/bg8.jpg"width="534"height="410"> </body> </html> index4.php <html> <head> <metahttp-equiv="Content-Type"content="text/html; charset=gb2312"> <title>無標題文檔</title> </head> <body> <imgsrc="images/bg7.JPG"width="538"height="520"> </body> </html> 二 運行結果
  三 功能說明 應用switch語句設計網站首頁的布局,將網站頭、尾檔案設定為固定不變的板塊、導航條也作為固定板塊;而在主顯示區中,應用switch語句根據超連結中傳遞的值不同,顯示不同的內容。 大小: 315.1 KB 查看圖片附件

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.