Home › Forums › Quform WordPress › Populating a Dropdown with Both Static and Dynamic Content
- This topic has 2 replies, 2 voices, and was last updated 10 years, 11 months ago by lawrencepepper.
- AuthorPosts
- February 17, 2014 at 5:50 pm #8762lawrencepepperParticipant
I am populating a drop down with dynamic content from a query. I am using the following code in my functions file:
#Populate the Employee Custom Report Dropdown Listfunction c_employee_dynamic_dropdown_values($form)
{if (is_user_logged_in()) {
global $current_user;
get_currentuserinfo();
$person = $current_user->user_login;
}$options = array();
$dbc = mysqli_connect('localhost', 'xxx', 'xxx', 'time');
$query = "SELECT * FROM employee ORDER BY last_name ASC";
$result = mysqli_query($dbc, $query);while ($row = mysqli_fetch_assoc($result)) {
$options[] = array('label' => $row['last_name'].', '. $row['first_name'],'value' => $row['user_name']);}
$dropdown = $form->getElement('iphorm_19_6');
if ($dropdown instanceof iPhorm_Element_Select) {
$dropdown->setOptions($options);
}
}add_action('iphorm_pre_display_19', 'c_employee_dynamic_dropdown_values');
I need to have the first item in the drop down be All. The label and the value both need to be All, then I need all the dynamic content being grabbed by this query to be under in the list.
How can I do that, I can only seem to populate the list with the dynamic content. I can not figure out how to put the static All value in the list.
February 18, 2014 at 9:21 am #8770AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
February 18, 2014 at 1:56 pm #8780lawrencepepperParticipantYes!
That worked, Thanks!
L
- AuthorPosts
- You must be logged in to reply to this topic.