简单判断可以用三目运算常用
判断次数多的情况下考虑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, "checkboxes[]")" 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>