You're throwing away a result row when you do $sth->fetchColumn()
. That's not how you check if there's any results. you do
if ($sth->rowCount() > 0) {
... got results ...
} else {
echo 'nothing';
}
relevant docs here: http://php.net/manual/en/pdostatement.rowcount.php