Populating a Dropdown with Both Static and Dynamic Content

Home Forums Quform WordPress Populating a Dropdown with Both Static and Dynamic Content

This topic is: resolved
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #8762
    lawrencepepper
    Participant

    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 List

    function 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.

    #8770
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #8780
    lawrencepepper
    Participant

    Yes!

    That worked, Thanks!

    L

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy