Viewing 1 replies (of 1 total)
  • Thread Starter henrywong10

    (@henrywong10)

    Hi,

    I have successfully populated a select dropdown list from database but it seems like cf7 can’t detect the values of the list. It causes validation error as cf7 can’t detect the values of the list. However, I can view the list from my form.

    Below is the code:

    if ( ‘project_contact_name’ == $name) {

    $vendors = mysql_query(“SELECT * from vendor”);

    while ($row = mysql_fetch_assoc($vendors)){
    $value = $row[‘values’];
    $selected = false;

    if ( $posted ) {
    if ( $multiple && in_array( esc_sql( $value ), (array) $_POST[$name] ) )
    $selected = true;
    if ( ! $multiple && $_POST[$name] == esc_sql( $value ) )
    $selected = true;
    } else {
    if ( ! $empty_select && in_array( $key + 1, (array) $defaults ) )
    $selected = true;
    }

    $selected = $selected ? ‘ selected=”selected”‘ : ”;

    $label = $value;

    $html .= ‘<option value=”‘ . esc_attr( $value ) . ‘”‘ . $selected . ‘>’ . esc_html( $label ) . ‘</option>’;
    }

    } else {


    }

    Any helps will be much appreciated!

    Thanks,

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Contact Form 7] Possible to load select dropdown values from mysql database?’ is closed to new replies.