timmle Posted October 7, 2009 Share Posted October 7, 2009 I am currently using open source php shopping cart and moving into learning a bit more on php and mysql but was wondering if anyone can help me with this. In my database i have a prescription_drop table. In there i have a list of fields but i am just concentrating on one for now so i can apply this to the rest of my project. The field is called rsph_drop inside the prescription_Drop table. This only has one column as i just want to output a list of values that are +10.00, +9.75, +9.50, +9.25, +9.00 and so forth. At the moment i have a text input field which writes to the database in a different area, but i want to change this into a drop down field which writes to the database in a different area. So as i understand it, please correct me if i am wrong, i have to build the values in a table in my database, request information from the database to populate that drop down menu, and then with the one chosen input into the database. So i have this so far on the page... $rsph = tep_db_prepare_input($HTTP_POST_VARS['rsph']); $sql_data_array = array('customers_rsph' => $rsph, <td class="main"><?php echo ENTRY_CUSTOMER_RSPH; ?></td> <td class="main"><?php echo tep_draw_input_field('rsph', '','maxlength="6"' . 'style="width: 50"') . ' ' . (tep_not_null(ENTRY_RSPH_TEXT) ? '<span class="inputRequirement">' . ENTRY_RSPH_TEXT . '</span>': ''); ?></td> This is already part of a larger form with other input fields and such so the form part isn't necessary. the tep_draw_input_field is how this open source software draws a open text field and to put in a drop down menu it is tep_draw_pull_down. I don't mind changing this for generic php commands. What i really need to know is how take the information from the rsph_drop fields in the prescription_drop table to populate a drop down menu. And then allow this information to enter into the 'rsph' field in the 'customers' table Thankyou. Quote Link to comment Share on other sites More sharing options...
Psycho Posted October 7, 2009 Share Posted October 7, 2009 It is difficult to tell you how to accomplish this without knowing how the tep_draw_pull_down() function operates. What are the parameters for that function and what do they do? For example, how do you pass it the values? I would suspect it takes an array for the values (and possibly the labels). So, you can either create a hard-coded list or generate the list from a database. If the list will never (or rarely) change, then a hard-coded list is the easier way to go. if the list will change often, then you can create the list in a database and then create functionality to give an admin the ability to modify the list. Quote Link to comment Share on other sites More sharing options...
Psycho Posted October 7, 2009 Share Posted October 7, 2009 Ok, a little googling came up with the function tep_draw_pull_down_menu for the OsCommers application. The parameters are: tep_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) And $values appears to need to be a multi-dimensional array in the format array ( [0] => array ( ['id'] => '1', ['text'] => 'Value 1' ), [1] => array ( ['id'] => '2', ['text'] => 'Value 2' ) ) Quote Link to comment 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.