Title: Count, exclude row if empty field
Last modified: March 6, 2017

---

# Count, exclude row if empty field

 *  Resolved [mackans](https://wordpress.org/support/users/mackans/)
 * (@mackans)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/count-exclude-row-if-empty-field/)
 * 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](https://wordpress.org/support/users/mackans/)
 * (@mackans)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/count-exclude-row-if-empty-field/#post-8884942)
 * 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](https://wordpress.org/support/users/mackans/)
 * (@mackans)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/count-exclude-row-if-empty-field/#post-8886436)
 * Solved. See this thread for solution: [https://wordpress.org/support/topic/use-the-count-shortcode-inside-a-php-function/](https://wordpress.org/support/topic/use-the-count-shortcode-inside-a-php-function/)

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

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

 * ![](https://s.w.org/plugins/geopattern-icon/contact-form-7-to-database-extension_ffffff.
   svg)
 * [Contact Form DB](https://wordpress.org/plugins/contact-form-7-to-database-extension/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7-to-database-extension/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7-to-database-extension/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7-to-database-extension/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7-to-database-extension/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7-to-database-extension/reviews/)

 * 2 replies
 * 1 participant
 * Last reply from: [mackans](https://wordpress.org/support/users/mackans/)
 * Last activity: [9 years, 2 months ago](https://wordpress.org/support/topic/count-exclude-row-if-empty-field/#post-8886436)
 * Status: resolved