This is a follow up question to my previous question in here. PHP - Dropdown menu(select) not working properly to while loop
I follow the code given to me and I think it is working correctly. But my only concern is that, the query in my code is actually for the shelf
table, and not for the book
table which have the foreign key for the shelf. Here is my code for the textfield. It is in a form which have a button that redirects to check_book.php to add it
<div class="form-group">
<label for="inputEmail" class="col-lg-2 control-label">Shelf</label>
<div class="col-lg-10">
<?php
$sel_admin = "select * from shelf";
$rs_admin = mysql_query($sel_admin);
echo '<select class="form-control">';
while($row = mysql_fetch_array($rs_admin))
{
echo"<option value='" .$row['shelf_id']."'>" . $row['shelf_description'] ."</option>";
}
echo'</select>';
?>
</div>
</div>
It's giving me this error Notice: Undefined index: shelf_id in C:\\xampp\\htdocs\\OCatalog\\admin\\check_book.php on line 8
but the other non-foreign key textfield is just fine.
And here is my check_book.php
$book_id = $_POST['book_id'];
$book_title = $_POST['book_title'];
$author_id = $_POST['author_id'];
$book_quantity = $_POST['book_quantity'];
$shelf_id = $_POST['shelf_id'];
How can I view all the shelf
then adding it as a foreign key?
PS. The select is also in the form
which when i click the submit button it will go to check_book.php
您忘记在选择中添加名称属性
echo '<select class="form-control" name="shelf_id">';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.