How do I make the contents of drop down menus dynamic?
What I mean is I want users to be able to add a product to inventory, and it show up in the order form's drop down menu box for selection. I'm not sure how to pull this from the database and have it show up a new entry when a new item is entered into inventory.
Anyone know how I could do this? Let's say the table that has all the inventory is inventory, and the feild that has the contents of the drop down box is called sizes.
-ee99ee
PHP and HTML drop down menus
Moderator: General Moderators
Drop down menu
if you mean you want a drop list in a form.
You can do this.
1. create a table to record your inventroy
------------------
ID | Name
------------------
1 Book
2 computer
-----------------
2. in the form page. You just select all rows from this table and make up a drop down list.
<?php
$q="select * from inventroy";
$dis="<select name=\"inventory\" size=\"1\">\n";
while( $r=mysql_fetch_array( mysql_query( $q ) ){
$dis.="<option value=\".$r['ID']."\">".$r['Name']."</option>\n";
}
$dis.="</select>";
?>
you can just use
<?=$dis?>
to have a drop down list whose options are coming from inventory table.
You can do this.
1. create a table to record your inventroy
------------------
ID | Name
------------------
1 Book
2 computer
-----------------
2. in the form page. You just select all rows from this table and make up a drop down list.
<?php
$q="select * from inventroy";
$dis="<select name=\"inventory\" size=\"1\">\n";
while( $r=mysql_fetch_array( mysql_query( $q ) ){
$dis.="<option value=\".$r['ID']."\">".$r['Name']."</option>\n";
}
$dis.="</select>";
?>
you can just use
<?=$dis?>
to have a drop down list whose options are coming from inventory table.