I've got an array in my SQL database. Each record has three fields.
I'm running a query and assigning the data to an array called $itemsarray.
Field one is the primary key, INT 10, auto increment.
Field two is the item_name, VARCHAR 50.
Field three is the item_number, which is like an inventory number, INT 10.
I would like to generate a dropdown list with field two, and whichever one is selected, pass field three on to the next page.
I'm trying this code but it doesn't work:
I'm calling that function with this line:Code:function generateSelect($name = '', $options = array(id, item_name, item_number)) { $html = '<select name="'.$name.'">'; foreach ($options as $option => $value)// { $html .= '<option value='.$value.'>'.$option[item_name].'</option>'; } $html .= '</select>'; return $html; }
My brain is fried and I can't figure out what I'm doing wrong.Code:$dropdownlist=generateSelect('Item List', $itemsarray); echo $dropdownlist;
Thanks in advance,
JIM



Reply With Quote



