Chris Chris -5 years ago 150
PHP Question

Count empty mysql columns in PHP

I'm trying to create a method that counts the empty mysql columns.

My code is as follows:

public function countCompletion() {
$userData = $this->find(Session::get('user'));
$userData = $this->_data;

$completion = 0;

foreach($userData as $item) {
if(empty($item)) {


The problem is, when I die
it just shows nothing, while it should show 2.

Answer Source

According to the documentation, when die (or exit) is called with an integer argument the argument is not printed but is instead passed back to the operating system as an exit code. To get the value to display you will need to return it, then print it from the calling routine.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download