Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8969057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:32:24+00:00 2026-06-15T17:32:24+00:00

I have used the Facebook PHP SDK to fetch the pages user likes. $liked

  • 0

I have used the Facebook PHP SDK to fetch the pages user likes.

$liked = $facebook->api('/me/likes');

After decoding the JSON I get the output array something like this:

Array ( 
[data] => Array ( 
[0] => Array ( [category] => Book [name] => Steve Jobs by Walter Isaacson [id] => 152707268157952 [created_time] => 2012-12-05T15:10:14+0000 ) 
[1] => Array ( [category] => Internet/software [name] => Evernote [id] => 30670583128 [created_time] => 2012-11-24T04:39:25+0000 ) 
[2] => Array ( [category] => Product/service [name] => HTC [id] => 112176482203770 [created_time] => 2012-11-15T06:36:59+0000 )
....
....
....
)

I want to store the category and name of every page the user has liked into the database table. I want to store it in such a way that I can efficiently compare two users, and get mutually liked pages. For example: When a user wants to compare the books in common with another user, the user can get the mutually liked books.

How should I store the data from the array into the table in such a way that I can use it later for comparisons.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:32:25+00:00Added an answer on June 15, 2026 at 5:32 pm

    Create a table (liked_pages) with columns for all the data you wish to store:

    • user_id
    • category
    • name
    • id
    • created_time

    Store the data from your array in this table.

    Then given two user_ids (for this example, let’s say 1 and 2), to find mutually liked pages you could do the following:

    SELECT id FROM liked_pages
    WHERE user_id IN (1,2)
    GROUP BY id
    HAVING COUNT(id) = 2
    

    If you wanted to extend this to only find mutually liked pages in a certain category (let’s say ‘books’), you would add an additional where clause category = 'books'.

    Edit:

    To expand on the questions you are asking in the comments, it is best practise to store only one record per row in a database table as this allows you to search and sort for relevant records when retrieving data, something which database engines are optimised for.

    The alternative to this would be to serialize the array and store only one entry per
    user and then retrieve the array from the database, unserialize it and then do all of the searching/sorting in PHP but this would be less efficient.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used the Facebook PHP SDK to fetch the books user liked. $books
i have used this code in my index.php to get user facebook first name
Regards, I have a problem with Facebook SDK-PHP and Codeigniter. I do not get
I have used facebook PHP SDK which generates login Url . Which I simply
I've used this code to have a like btn on my site: <iframe src=http://www.facebook.com/plugins/like.php?href=URL_OF_YOUR_WEBSITE&amp;send=false&amp;layout=standard&amp;width=450&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font&amp;height=80&amp
I'm using the Facebook php-sdk to get the users name and friends, right now
I'm trying to use the Graph API and the PHP SDK for Facebook to
I have an application on Facebook which has two pages, index.php and admin.php. On
Using the Facebook Graph API and the PHP SDK, I know that I can
I have PHP-Class to work with Facebook API: class Social { private $name; private

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.