• Resolved mackans

    (@mackans)


    Hi

    Your code below works great for counting the number of submissions! I have another question now. How can I make the function to exclude rows that has a value in a certain column?

    For example, in the form I have a field that is optional to fill in. If the field is left blank I don’t want to include this submission (the row in the database) in the count function.

    require_once(ABSPATH . 'wp-content/plugins/contact-form-7-to-database-extension/CFDBFormIterator.php');
    $exp = new CFDBFormIterator();
    $exp->export('Registration', array('show' => 'submit_time', 'trans' => 'CountField(submit_time)'));
    $count = 0;
    while ($row = $exp->nextRow()) {
        $count = $row['submit_time'];
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter mackans

    (@mackans)

    EDIT: I have to clarify my first post as I’ve noticed it’s not understandable at all…

    This is what I mean: The function above counts all submissions based on the ‘submit_time’ column. I have another column namned ‘registrationcode’. Out of 100 submissions, only 5 submissions has a value in this column. I want to exclude those 5 rows from the count function (or any row that has a value in that column). In other words, I only want to include the rows that has an empty value in the column ‘registrationcode’.

    Thanks

    Thread Starter mackans

    (@mackans)

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Count, exclude row if empty field’ is closed to new replies.