Home › Forums › Quform WordPress › Database Dropdown
- This topic has 5 replies, 2 voices, and was last updated 8 years ago by
Ally.
- AuthorPosts
- August 23, 2017 at 4:30 pm #21663
webs911
ParticipantTrying to populate a dropdown with values from a database table. I’ve read through previous posts and followed your instructions diligently, but still having problems getting it to work. Please help:
//function mytheme_dynamic_dropdown_values($form)
//{
//$options = array();
//$dbc = mysql_connect(‘localhost’, ‘root’, ‘password’, ‘user’);
//$query = “SELECT * FROM e2015730_nigp”;
//$result = mysql_query($dbc, $query);
//$data_array = array();
//while ($row = mysql_fetch_assoc($result)) {
//$options[] = array(‘label’ => $row[‘NIGP Code’], ‘value’ => $row[‘NIGP Code’]);
//}//$dropdown = $form->getElement(‘iphorm_6_47’);
//if ($dropdown instanceof iPhorm_Element_Select) {
//$dropdown->setOptions($options);
//}
//}
//add_action(‘iphorm_pre_display_6’, ‘mytheme_dynamic_dropdown_values’);- This topic was modified 8 years ago by
webs911.
August 24, 2017 at 9:54 pm #21669Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
August 25, 2017 at 7:59 pm #21673webs911
ParticipantThanks for your response, Ally. Was I also supposed to add a shortcode to the form field to connect to my php code? Didn’t see any reference to that on the knowledge base here. I’m using a “single line text” field for this. Thanks.
- This reply was modified 8 years ago by
webs911.
Attachments:
You must be logged in to view attached files.September 3, 2017 at 12:48 pm #21688Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
September 5, 2017 at 7:44 pm #21754webs911
ParticipantPerhaps my question wasn’t clear enough. I’ve used the code to create the plugin to connect to my database. Now, how do I display my data (from the database) in the dropdown field in form builder?
September 6, 2017 at 8:52 pm #21779Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- This topic was modified 8 years ago by
- AuthorPosts
- You must be logged in to reply to this topic.