我有三个选择标签(1)类别,(2)子类别,(3)产品描述,我想用数据库中的数据填充它。但是我想要的是当我选择例如。子类别上的类别中的办公用品将仅显示例如。圆珠笔、尺子、笔记本以及当我选择时。产品说明上的圆珠笔只会显示圆珠笔的说明。顺便说一句,我创建了一些由 PHP 编写的代码,但它只填充了选择标签。我希望有人能帮助我。这是为了毕业论文。:)
<html>
<head>
<title>Test Select</title>
</head>
<body>
<?php
$query = "SELECT DISTINCT(`product_cate`) FROM `tbl_product` ";
$result = mysql_query($query);
?>
Category:
<select id="select1">
<option></option>
<?php while($data = mysql_fetch_array($result)){
$displayData = $data['product_cate'];
?>
<option value="<?php echo $displayData;?>"><?php echo $displayData; ?></option>
<?php } ?>
</select>
<?php
$query2 = "SELECT DISTINCT(`product_sub`) FROM `tbl_product`";
$result2 = mysql_query($query2);
?>
Sub Category:
<select id="select2">
<option></option>
<?php while($data2 = mysql_fetch_array($result2)){
$displayData2 = $data2['product_sub'];
?>
<option value="<?php echo $displayData2;?>"><?php echo $displayData2;?></option>
<?php }?>
</select>
<?php
$query3 = "SELECT DISTINCT(`product_desc`) FROM `tbl_product`";
$result3 = mysql_query($query3);
?>
Product Description:
<select id="select3">
<option></option>
<?php while($data3 = mysql_fetch_array($result3)){
$displayData3 = $data3['product_desc'];
?>
<option value="<?php echo $displayData3;?>"><?php echo $displayData3;?></option>
<?php }?>
</select>
</body>
</html>