我一直在尝试从选择框生成数据,我对数据库做了一个简单的查询,它将在选择框中生成类别列表。现在我的问题是,如何从另一个表中获取数据,如果正在选择选择框,它将立即显示。我相信有一个与此相关的JavaScript更容易的方式。有人可以告诉我,或说明应该怎么做?
<select name="categoryID" id="" class="form-control" required>
<option value="" default>SELECT</option>
<?php
$select = $conn->query("SELECT * FROM category");
while ($row = $select->fetch_assoc()) {
$showlumber = $conn->query("SELECT * FROM inventorylumber WHERE categoryID = '$row[categoryID]'");
$rowLumber = $showlumber->fetch_assoc();
?>
<option value="<?php echo $row['categoryID']; ?>"><?php echo $row['categoryName']; ?>
</option>
<?php } ?>
</select>
</div>
<thead>
<tr>
<th>2 x 2</th>
<th><?php echo $rowLumber['2x2x6']; ?>Pcs</th>
<th><?php echo $rowLumber['2x2x8']; ?>Pcs</th>
<th><?php echo $rowLumber['2x2x10']; ?>Pcs</th>
<th><?php echo $rowLumber['2x2x12']; ?>Pcs</th>
<th><?php echo $rowLumber['2x2x14']; ?>Pcs</th>
<th><?php echo $rowLumber['2x2x16']; ?>Pcs</th>
</tr>
</thead>