Support » Plugin: Contact Form DB » Display data into combo and search

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Michael Simpson


    Refer to the post on creating a form to search the database.

    To add a select to the form you could use [cfdb-html] to generate the option tags:

    <form action="" method="POST">
        <select name="field-name">
          [cfdb-html form="form-name" show="field-name"]
              <option value="${field-name}">${field-name}</option>
    [cfdb-table form="form-name" filter="fname~~/.*$_POST(field-name).*/i"]

    Change “field-name” and “form-name” to your field/form.

    Hi Michael.
    First, congratulations for CFDB plugin, it’s a great plugin, very usefull.

    My need is the same above, but i need show the distinct values.

    Example: Many people submit a form. I create a page for filter this submissions, using shortcode cfdb-html to show the name of those people into combo, like your post above. But, one person can submit more than one form, and I need show the name of people into combo without repeat. Is possible?

    Using mysql_query, I know it’s possible (select distinct column-name).

    And using shortcode? If not, you could add this feature for plugin, some like [cfdb-html distinct=field-name].

    All the best. Thanks again for support.

    Plugin Author Michael Simpson


    Unfortunately the short codes don’t have a “distinct” option. You would have to resort to creating your own short code, something like this:

    require_once(ABSPATH . 'wp-content/plugins/contact-form-7-to-database-extension/CFDBFormIterator.php');
    $exp = new CFDBFormIterator();
    $exp->export($atts['form'], $atts);
    $names = array();
    while ($row = $exp->nextRow()) {
        $names[] = $row['field-name'];
    $distinctNames = array_unique($names);
    foreach ($distinctNames as $name) {
        echo "<option value=\"$name\">$name</option>";

    Hello Michael.

    Your solution works perfectly! Thanks for your good support.

    Best regards.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display data into combo and search’ is closed to new replies.