This question already has an answer here:
The project that i am doing is online and it has 3 branches. I wanted to check other branch inventory when I select the branch in drop down and press "Generate" button as fancy box preview. Bellow is the code of 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>
and otherinventory.php code,
.... html codes ...
<?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 codes ...
Then it gives
Notice: Undefined index: Branch anyone could please help me to solve this ?
</div>