SirChick Posted August 25, 2007 Share Posted August 25, 2007 Is there a way to add to this by using infomation on my table. Basically my table will have price and type and i want to add those 2 in the list so that it will look like this: £12,000 - Steel £12,500 - Wood And because its a list box the user can then click which ever one and then i can submit it using a form ? ( i can do the form bit) but i cannot do the bit where by it creates the list in the box.. this is the html of the box so far: <select name="Combobox3" size="2" id="Combobox3" style="position:absolute;left:343px;top:662px;width:223px;font-family:MS Shell Dlg;z-index:25"> </select> Quote Link to comment https://forums.phpfreaks.com/topic/66645-creating-list-box-using-fields-on-my-db/ Share on other sites More sharing options...
ksmatthews Posted August 25, 2007 Share Posted August 25, 2007 Hi There, Why not create a bespoke function like this and call it ... // FUNCTION: dynamically creates and loads data into a <select> HTML object // PARAMETERS required: FOUR Strings + ONE myDatabase Object // RETURNS: HTML code for a drop down list function create_dropdown_list($myDB, $SQL, $table, $attribute, $label) { // initialise list $list = '<select name = "' . $label . '">'; // run SQL query $dbResult = $myDB->ODBC_get_data($SQL, TABLE_ACCESS_ERROR . $table, TABLE_DATA_ERROR . $table); // create <option data> do { // capture data and assemble select options $list .= "<option value='" . odbc_result ($dbResult, $attribute) . "' name='value'>" . odbc_result ($dbResult, $attribute) . "</option>"; // fetch next row $row = odbc_fetch_row($dbResult); } while(TRUE == $row); // close list $list .= '</select>'; return $list; } Quote Link to comment https://forums.phpfreaks.com/topic/66645-creating-list-box-using-fields-on-my-db/#findComment-333945 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.