看看就好 有些功能没拿出来,主要还是看如何循环遍历,以及select选中值,还有学习一下模板标签
<ul id="attr_list">
<?php foreach ($attr as $k=>$v):?>
<li>
<?php if($v['attr_type'] == 2):?>
<a onclick="addnewattr(this);" href="javascript:void(0);">[+]</a>
<?php endif;?>
<?php echo $v['attr_name'];?>:
<?php if($v['attr_option_values']):
$attrvalues = explode('|',$v['attr_option_values']);
?>
<select>
<option value="">请选择</option>
<?php foreach ($attrvalues as $v1):
if ($v1 == $v['attr_value'])
{
$select = 'selected="selected"';
}
else
{
$select = '';
}
?>
<option <?=$select?> value="<?=$v1?>"><?=$v1?></option>
<?php endforeach;?>
</select>
<?php else:?>
<input type="text" name="" value="<?php echo $v['attr_value']?>" />
<?php endif;?>
</li>
<?php endforeach; ?>
</ul>