Re: [PHP-DB] Navigation Help

[email protected] (Chris)
Newsgroups php.db
Message-ID <[email protected]>
>  $result = safe_query("select count(*) FROM gig g, venue v WHERE g.gigName LIKE '%".$gig_name."%' ");
>  $noEntries = mysql_num_rows($result);
>  $noPages = ceil($noEntries / $limit);

$noEntries is always going to be 1 - there is a single row with the
'count' in it.

What you probably want is:

$result = safe_query('select count(*) AS count from ... ....');
$noEntries = mysql_fetch_assoc($result['count']);

or

// since we're not 'aliasing' the result, i dont know what it will be
called in the $row array.
// so just pop it.

$result = safe_query("select count(*) from ...";
$row = mysql_fetch_assoc($result);
$noEntries = array_pop($row);

-- 
Postgresql & php tutorials
http://www.designmagick.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.