【发布时间】:2014-10-08 09:16:27
【问题描述】:
此代码适用于类别和子类别。在类别中,我在下拉列表中显示所有值,但对于子类别,我想显示属于某个类别的确切子类别。请帮助我
<div class="form-group">
<label for="exampleInputEmail1">Category Name</label>
<select name="type" id="type">
<option>Select Category</option>
<?php
$res= mysql_query("select * from ".CATEGORY." order by id asc");
while($data=mysql_fetch_array($res))
{
?>
<option value="<?php echo $data['id'];?>"><?php echo $data['cat_name'];?></option>
<?php } ?>
</select>
</div>
<div class="form-group">
<label for="exampleInputEmail1">Subcategory Name</label>
<select name="type1" id="type1">
<option>Select Category</option>
<?php $res= mysql_query("select * from ".SUBCATEGORY." order by id asc");
while($data=mysql_fetch_array($res))
{
?>
<option value="<?php echo $data['id'];?>"><?php echo $data['sub_name'];?></option>
<?php } ?>
</select>
</div>
【问题讨论】:
-
使用 Ajax 获取子类别
标签: php