Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.