 <pre><code>while($row = $s-&gt;fetch()) { foreach($row as $val) { if(empty($val)) { $flag = 1; } } } </code></pre> <p>'empty()' assumes you want to catch null, false, empty strings, and zeros. If you don't want to catch zeros/false, use <code>if(is_null($val) || $val == '') { $flag = 1; }</code></p>