常见输出页面:switch

简单判断可以用三目运算常用

判断次数多的情况下考虑switch:

<td nowrap="true" valign="top"><span>
      <?php 
        switch ($attr['attr_input_type']){
          case 0:
            echo "手工录入";
            break;
          case 1:
            echo "从下拉列表中选择";
            break;
          case 2:
            echo "多行文本";
            break;
        }

      ;?>
      </span></td>

参考:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="application/views/admin/styles/general.css" rel="stylesheet" type="text/css" />
<link href="application/views/admin/styles/main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="form-div">
  <form action="" name="searchForm">
    ![](application/views/admin/images/icon_search.gif)
    按商品类型显示:<select name="goods_type" onchange="searchAttr(this.value)"><option value="0">所有商品类型</option>
    <?php foreach ($types as $type) :?>
      <option value="<?php echo $type['type_id'];?>" 
      <?php echo $type['type_id'] == $type_id ? "selected = 'selected'" : "" ?>
      ><?php echo $type['type_name'];?></option>
    <?php endforeach;?>
    </select>
  </form>
</div>

<form method="post" action="attribute.php?act=batch" name="listForm">
<div class="list-div" id="listDiv">

  <table cellpadding="3" cellspacing="1">
    <tbody>
        <tr>
            <th><input onclick="listTable.selectAll(this, &quot;checkboxes[]&quot;)" type="checkbox">编号 </th>
            <th>属性名称</th>
            <th>商品类型</th>
            <th>属性值的录入方式</th>
            <th>可选值列表</th>
            <th>排序</a></th>
            <th>操作</th>
        </tr>
      <?php foreach ($attrs as $attr) :?>
        <tr>
            <td nowrap="true" valign="top"><span><input value="1" name="checkboxes[]" type="checkbox">1</span></td>
            <td class="first-cell" nowrap="true" valign="top"><span onclick="listTable.edit(this, 'edit_attr_name', 1)"><?php echo $attr['attr_name'];?></span></td>
            <td nowrap="true" valign="top"><span><?php echo $attr['type_name'];?></span></td>
            <td nowrap="true" valign="top"><span>
      <?php 
        switch ($attr['attr_input_type']){
          case 0:
            echo "手工录入";
            break;
          case 1:
            echo "从下拉列表中选择";
            break;
          case 2:
            echo "多行文本";
            break;
        }

      ;?>
      </span></td>
            <td valign="top"><span><?php echo $attr['attr_value'];?></span></td>
            <td align="right" nowrap="true" valign="top"><span onclick="listTable.edit(this, 'edit_sort_order', 1)">0</span></td>
            <td align="center" nowrap="true" valign="top">
                <a href="index.php?p=admin&c=attribute&a=edit&attr_id=<?php echo $attr['attr_id'];?>" title="编辑">![](application/views/admin/images/icon_edit.gif)</a>
                <a href="index.php?p=admin&c=attribute&a=delete&attr_id=<?php echo $attr['attr_id'];?>" onclick="removeRow(1)" title="移除">![](application/views/admin/images/icon_drop.gif)</a>
            </td>
        </tr>
    <?php endforeach;?>

      
      </tbody></table>

  <table cellpadding="4" cellspacing="0">
    <tbody><tr>
      <td style="background-color: rgb(255, 255, 255);"><input type="submit" id="btnSubmit" value="删除" class="button" disabled="true"></td>
      <td align="right" style="background-color: rgb(255, 255, 255);">      <!-- $Id: page.htm 14216 2008-03-10 02:27:21Z testyang $ -->
            <div id="turn-page">
        <?php echo $pageinfo;?>
        <!--
        总计  <span id="totalRecords">12</span>
        个记录分为 <span id="totalPages">2</span>
        页当前第 <span id="pageCurrent">1</span>
        页,每页 <input type="text" size="3" id="pageSize" value="10" onkeypress="return listTable.changePageSize(event)">
        <span id="page-link">
          <a href="javascript:listTable.gotoPageFirst()">第一页</a>
          <a href="javascript:listTable.gotoPagePrev()">上一页</a>
          <a href="javascript:listTable.gotoPageNext()">下一页</a>
          <a href="javascript:listTable.gotoPageLast()">最末页</a>
          <select id="gotoPage" onchange="listTable.gotoPage(this.value)">
            <option value="1">1</option><option value="2">2</option>          </select>
        </span>
        -->
      </div>
</td>
    </tr>
  </tbody></table>
</div>

</form>

<div id="footer">
    
</div>
<script type="text/javascript">
   function searchAttr(type_id){
      var url = "index.php?p=admin&c=attribute&a=index&type_id="+type_id;
      window.location.href = url ;
   }
</script>
</body>
</html>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1. Java基础部分 基础部分的顺序:基本语法,类相关的语法,内部类的语法,继承相关的语法,异常的语法,线程的语...
    子非鱼_t_阅读 31,778评论 18 399
  • 一、中药服用 服中药时禁忌:葱蒜,胡椒,羊肉,狗肉,茶叶,萝卜,鱼 二、具体药材 1、白芨①中文名:白芨②界:植物...
    潇湘妃子JC阅读 243评论 0 0
  • 夜已经深了,坐在幽暗的灯光下,手中握着文学大师郁达夫的作品,郁达夫就这样扑面走来,而我,也沉浸在他孤独的气质和深沉...
    绛洞花王阅读 9,076评论 34 63
  • 有时候 看到一个男孩子 会看穿他的内心 会理解他的一切 这太不可思议 而我不知道我会有这样的功能。
    相相相柳阅读 79评论 0 0
  • 萌猫“胖花”的主人Yixi有事回国一个月,走之前把宠猫托付给了我。我和Alex (以下称轻松熊)早就满怀期待,代管...
    Shou撕鬼子阅读 530评论 0 3