Hi there, I am trying to display data from my SQL as a drop-down field on a formidable form by way of hooking into the Formidable Forms filter. My code currently connects to the DB and fetches the data, but I'm having issues displaying the data through the drop-down field in the form. Nothing comes up. I previously tried displaying it via shortcode, which worked well on the HTML field in the formidable form, but apparently any input on the HTML field was not recognized on submission. Any help on this will be very much appreciated. Here is my code:
Start your code here add_filter('frm_setup_new_fields_vars', 'populate_dropdown_options'); function populate_dropdown_options($values) { if ($values['field_key'] == '***') { ob_start(); $db_server = "***"; $db_username = "***"; $db_password = "***"; $db_name = "***"; $conn = new mysqli($db_server, $db_username, $db_password, $db_name); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $query = "SELECT * FROM ***"; $result = $conn->query($query); if ($result->num_rows > 0) { echo '<select name="***">'; while ($row = $result->fetch_assoc()) { echo '<option value="' . $row['serial_numbers'] . '">' . $row['serial_numbers'] . '</option>'; } echo '</select>'; } else { echo "No data available."; } $conn->close(); $values['options'] = ob_get_clean(); } return $values; }