【发布时间】:2016-02-25 11:18:23
【问题描述】:
我正在做的项目是在线的,它有 3 个分支。当我在下拉列表中选择分支并按“生成”按钮作为精美框预览时,我想检查其他分支库存。下面是代码 inventory.php
<form action="otherinventory.php" method="POST">
<label class="control-label" for="selectError">Branch:</label>
<div class="controls3">
<select id="selectError3" name="Branch">
<?php
$query = 'SELECT branch_ID,branch_add from db_thisurienterprice.tbl_branch where branch_ID !=' . $_SESSION['username'];
$data = $conn->prepare($query); // Prepare query for execution
$data->execute(); // Execute (run) the query
while ($row2 = $data->fetch(PDO::FETCH_ASSOC)) {
echo '<option value="' . $row2['branch_ID'] . '">' . $row2['branch_add'] . '</option>';
}
?>
</select>
</div>
<!--<button type=submit class="fancybox fancybox.ajax" >Warehouse</button>-->
<div class="span"> <a href="otherinventory.php" class="fancybox fancybox.ajax"> <button class="btn btn-small btn-success" data-rel="tooltip" title="To add new product ">Generate </button> </a><div> <br/>
</form>
和otherinventory.php代码,
.... html 代码 ...
<?php
$sql = 'SELECT item_name , item_ID , qty
FROM tbl_item,tbl_inventory
WHERE tbl_inventory.tbl_item_item_ID = tbl_item.item_ID
AND tbl_branch_branch_ID = ' .$_POST['Branch'];
$stmt = $conn->prepare($sql);
$stmt->execute(array());
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
echo '<tr>';
echo '<td>' . $row[0] . '</td>';
echo '<td>' . $row[1] . '</td>';
echo '<td>' . $row[2] . '</td>';
echo '</tr>';
}
?>
.... html 代码 ...
然后它给了
注意:未定义索引:分支谁能帮我解决这个问题?
【问题讨论】:
-
检查帖子是否包含任何数据或未使用 print_r($_POST);
-
type=""在您的按钮中丢失并从按钮中换掉anchor tag