Friday, 9 August 2013

pdo get number of rows

pdo get number of rows

I am trying to get the number of rows using pdo and if the number is less
than 1 echo not found else do the other stuff. The below code isn't
displaying "not found" if there are no results matching the where clause.
$options = array(
'results_per_page' => 200,
'url' => 'index.php?page=*VAR*',
'db_handle' => $dbh
);
$page = $_GET['page'];
$paginate = new pagination($page, 'SELECT * FROM pants where size
="medium" or size ="M" ORDER BY id desc', $options);
$result = $paginate->resultset->fetchAll();
if($result > 0)
{
foreach($result as $row)
{
echo $row['title'];}
else {
echo "not found";}

No comments:

Post a Comment