`
cakin24
  • 浏览: 1337638 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

PHP用switch语句设计网站主页

    博客分类:
  • PHP
阅读更多

一 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
  1. <html>
  2. <head>
  3. <metahttp-equiv="Content-Type"content="text/html; charset=gb2312">
  4. <title>无标题文档</title>
  5. </head>
  6. <body>
  7. <imgsrc="images/bg6.jpg"width="508"height="543">
  8. </body>
  9. </html>
index2.php
  1. <html>
  2. <head>
  3. <metahttp-equiv="Content-Type"content="text/html; charset=gb2312">
  4. <title>无标题文档</title>
  5. </head>
  6. <body>
  7. <ahref="index.php?lmbs=新品上市"></a>
  8. <imgsrc="images/bg7.jpg"width="547"height="548">
  9. </body>
  10. </html>
index3.php
  1. <html>
  2. <head>
  3. <metahttp-equiv="Content-Type"content="text/html; charset=gb2312">
  4. <title>无标题文档</title>
  5. </head>
  6. <body>
  7. <a href="index.php?lmbs=<?php echo urlencode("特价区");?>"></a>
  8. <imgsrc="images/bg8.jpg"width="534"height="410">
  9. </body>
  10. </html>
index4.php
  1. <html>
  2. <head>
  3. <metahttp-equiv="Content-Type"content="text/html; charset=gb2312">
  4. <title>无标题文档</title>
  5. </head>
  6. <body>
  7. <imgsrc="images/bg7.JPG"width="538"height="520">
  8. </body>
  9. </html>
二 运行结果

 
三 功能说明
应用switch语句设计网站主页的布局,将网站头、尾文件设置为固定不变的板块、导航条也作为固定板块;而在主显示区中,应用switch语句根据超链接中传递的值不同,显示不同的内容。
  • 大小: 315.1 KB
1
0
分享到:
评论

相关推荐

    PHP Switch 语句之学习笔记

    Switch 语句 如果您希望有选择地执行若干代码块之一,请使用 Switch 语句。 使用 Switch 语句可以避免冗长的 if..elseif..else 代码块。 语法 复制代码 代码如下: switch (expression) { case label1: code to be ...

    php中switch语句用法详解

    本文介绍php中的switch语句的用法,它跟其他语句中的switch用法差不多的,但注意有有一个break语句。 PHP中switch语句的标准语法: switch (expression) { case label1: code to be executed if expression = ...

    PHP中的switch语句的用法实例详解

    switch 语句用于基于不同条件执行不同动作。本文给大家介绍php中的switch语句的用法实例详解,涉及到switch用法方面的知识点,对switch用法感兴趣的朋友通过本文一起学习吧

    PHP条件控制语句:if和switchi

    PHP条件控制语句:if和switchi

    php switch语句多个值匹配同一代码块应用示例

    先说说switch()语句的格式 ...仅当一个 case 语句中的值和 switch 表达式的值匹配时 PHP 才开始执行语句,直到 switch 的程序段结束或者遇到第一个 break 语句为止。如果不在 case 的语句段最后写上 bre

    php switch语句多个值匹配同一代码块的实现

    switch 语句一行接一行地执行(实际上是语句接语句),下面为大家介绍下php switch语句多个值匹配同一代码块

    PHP编程基础--表达式与语句.ppt

    二、条件语句 4.switch语句 switch语句用于根据表达式的值确定在几种不同值时执行不同的语句块,其语法格式如下: 三、循环语句 循环结构用于重复执行某一语句块,在PHP中提供了3种形式的循环语句:while循环语句、...

    邓炜PHP基本语法(三)流程控制语句

    PHP基本语法(三)流程控制语句 ... (2)switch语句(多分支) (3)三元操作符 二、循环语句 (1)for循环 (2)while循环 (3)do…while循环 优酷网视频地址: http://v.youku.com/v_show/id_XMTYzMjcwNzg0.html

    PHP 基础实例教程(PHP网页实例版)

    PHP switch语句 PHP while循环 PHP for和foreach循环 PHP do...while循环 PHP break/continue/exit PHP 数组 PHP 数字索引数组 PHP 非数字索引数组 PHP 多维数组 PHP 数组排序 PHP 多维数组排序 PHP 随机数组排序 ...

    (第四讲) PHP条件语句的介绍与应用

    本讲大纲: 1、if 条件语句 2、switch 条件语句

    PHP的switch判断语句的“高级”用法详解

    只所以称为“高级”用法,是因为我连switch的最基础的用法都还没有掌握,so,接下来讲的其实还是它的基础用法! switch 语句和具有同样...下面两个例子使用两种不同方法实现同样的事,一个用一系列的 if 语句,另一个用

    PHP语言基础知识(超详细).md

    switch语句使用 while循环语句说明 for循环语句 goto循环语句 PHP函数基本语法 PHP数组结构 for循环遍历索引数组 常用操作数组函数 PHP正则表达式 PHP文件系统管理 fopen、fread、fclose操作读取文件 PHP创建和...

    PHP100视频教程 4:PHP条件语句介绍与应用.rar

    软件介绍 1、if 条件语句... 在多个条件当中使用Switch 更加精巧,格式如下 switch ($i) {  case 0:  echo "输出 0";  break;  case 1:  echo "输出 1";  break;  case 2:  echo "输出 2";  break;

    php 随机数的产生、页面跳转、件读写、文件重命名、switch语句

    刚做的一个项目中的部分代码,包含了php中随机数的产生、页面跳转、件读写、文件重命名、switch语句。

Global site tag (gtag.js) - Google Analytics