Hi all, I have some code in PHP that is used to count the number of rows returned from a MySQL query. here is the function
the $number_of_posts should (at least I thought it should) return a number of rows from the query. I've tried echoing this out on the page but nothing shows.
I've read quite a few posts in this forum about the code to count the rows but very few of them tell you how to display the result.
Any help would be appreciated
Cheers
Dean
-------------------------------------------------------------
"The most overlooked advantage of owning a computer is that if they foul up there's no law against whacking them around a bit."
Code:
function list_apps($start = null, $per_page = null)
{
$connection = db_connect();
$query = " SELECT *
FROM coll_downloads
WHERE dlapp = '1'
";
$result = mysql_query($query);
//counts the number of rows in the query
[COLOR=red]$number_of_posts = mysql_num_rows($result);[/color]
if($number_of_posts == 0)
{
return false;
}
if(isset($start)&& isset($per_page))
{
$query .=" LIMIT $start, $per_page";
}
$result = mysql_query($query);
//changes the result into an array using the result_to_array function
$result = result_to_array($result);
return array('result'=> $result, 'num_events'=> $number_of_posts);
}
I've read quite a few posts in this forum about the code to count the rows but very few of them tell you how to display the result.
Any help would be appreciated
Cheers
Dean
-------------------------------------------------------------
"The most overlooked advantage of owning a computer is that if they foul up there's no law against whacking them around a bit."