0
我想根據下面的數據庫顯示下拉列表。 (bom table)要顯示下拉菜單的值php
例如,當我從下拉列表中選擇'Table'時,它會顯示bom_description,bom_quantity和UOM。
bom_id |bom_description |product_id |finish_product |bom_quantity |UOM
1 Table Tops 1 Table 1 /PC
2 Table Legs 2 Chair 4 /PC
3 Chair Seat 3 1 /PC
4 Chair Back 4 1 /PC
5 Chair Legs 5 4 /PC
選擇產品:表(下拉列表)
(HTML表會顯示以下)
bom_description |bom_quantity |UOM
Table Tops 1 /PC
Table Legs 4 /PC
當我點擊椅子,它會顯示此
選擇產品:Chair(A drop下拉列表)
bom_description |bom_quantity |UOM
Chair Seat 1 /PC
Chair Back 1 /PC
Chair Legs 4 /PC
現在,這是我的代碼,但顯示內容的html表沒有出現。
<script src="script/jquery-1.11.1.min.js"></script>
<script>
$(document).ready(function() {
$(".itemTypes").change(function() {
if (this.value == 0) {
$("tr").show();
}
else {
$("tr").hide();
$(".header").show();
$("." + this.value).show();
}
});
});
</script>
<?php
session_start();
if (!isset($_SESSION['username'])) {
header('location: homepage.php');
}
//connect to database
include ("dbFunctions.php");
$queryBOM = "SELECT * FROM bom";
$resultBOM = mysqli_query($link, $queryBOM) or die(mysqli_error($link));
mysqli_close($link);
?>
Select Product:
<select class="itemTypes">
<option value="0">
all types
</option>
<?php
while ($row1 = mysqli_fetch_array($resultBOM)) {
?>
<option value="<?php echo $row1['finish_product']; ?>">
<?php echo $row1['finish_product']; ?>
</option>
<?php } ?></select>
<p>
<table border="1">
<tr>
<th>BOM Description</th>
<th>Quantity</th>
<th>UOM</th>
<th colspan="2">Action</th>
<?php
while ($row = mysqli_fetch_assoc($resultBOM)) {
$bom_description = $row['bom_description'];
$bom_quantity = $row['bom_quantity'];
$UOM = $row['UOM'];
?>
<tr>
<td><center><?php echo $bom_description; ?></center></td>
<td><center><?php echo $bom_quantity; ?></center></td>
<td><center><?php echo $UOM; ?></center></td>
<td><center>
<form method="post" action="editBOM.php">
<input type="hidden" name="bomID" value="<?php echo $bom_id; ?>" />
<input type="image" src="images/editicon.png" name="edit" value="edit" style="width:30px;height:30px;"/>
</center></form>
</td>
<td><center>
<form method="post" action="dodeleteBOM.php">
<input type="hidden" name="bomID" value="<?php echo $bom_id; ?>" />
<input type="image" src="images/deleteicon.png" name="delete" value="delete" style="width:25px;height:25px;"/>
</center></form>
</center></td>
<?php
}
?>
</tr>
如何解決這個問題?
嗨,我已經嘗試過,但內容不會顯示靜止 – Janice
是選擇填充? –