Jump to content

modify function to return 2 results


Lassie

Recommended Posts

I have a function to retireve books in a category selection.

The function returns an array of books.

I also want to return the number of books in the category so I can go on and paginate the results.

How can I include the variable $num_books with the return result?

 

function get_books($cat_id)
{
   // query database for the books in a category
   if (!$cat_id || $cat_id=='')
     return false;
   
   $query = "select * from products where cat_id='$cat_id'";
   $result = mysql_query($query);
  if (!$result)
  return false;
   $num_books = mysql_num_rows($result);
   if ($num_books ==0)
      return false;
   $result = db_result_to_array($result);
   return $result;
}

Link to comment
https://forums.phpfreaks.com/topic/122373-modify-function-to-return-2-results/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.