WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form DB
Display data into combo and search (5 posts)

  1. danicasati
    Member
    Posted 1 year ago #

    How.
    It would be possible to display all data in a column in a combobox, and when I clic, perform a search (filter) by selected data?

    http://wordpress.org/extend/plugins/contact-form-7-to-database-extension/

  2. Michael Simpson
    Member
    Plugin Author

    Posted 1 year ago #

    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-html]
        </select>
    </form>
    [cfdb-table form="form-name" filter="fname~~/.*$_POST(field-name).*/i"]

    Change "field-name" and "form-name" to your field/form.

  3. giovane_mar
    Member
    Posted 11 months ago #

    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.

  4. Michael Simpson
    Member
    Plugin Author

    Posted 11 months ago #

    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>";
    }
  5. giovane_mar
    Member
    Posted 11 months ago #

    Hello Michael.

    Your solution works perfectly! Thanks for your good support.

    Best regards.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic