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 7709515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:52:55+00:00 2026-06-01T00:52:55+00:00

With the following code I get all the pages I admin on Facebook using

  • 0

With the following code I get all the pages I admin on Facebook using FQL. I do not print them though.

$PageNames = $facebook->api('/fql', array('q' => 
        'SELECT name, page_id FROM page WHERE page_id IN (
               SELECT page_id FROM page_admin  WHERE  uid=me() )'));

Previously, I have added in my DB the *page_id* of some of my pages. My goal is to show the pages that I have not added to my DB yet. It is working correctly and the code is below.

  foreach($PageNames['data'] as $PageName) {
    $investigate_id = mysql_query("SELECT page_id FROM pages WHERE page_id='"
                                  .$PageName['page_id']."' LIMIT 1 ");

      if(mysql_num_rows($investigate_id) == 0) {
        echo $PageName['page_id'].$PageName['name'];
      }

  }

My problem/question is if somehow I can avoid the numerous DB calls because it makes the query for every page I admin. How can I achieve this?

  • 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-01T00:52:56+00:00Added an answer on June 1, 2026 at 12:52 am

    You may collect the IDs from results you got with FQL and then query DB for rows that exists in results to filter those present in DB from results…

    $fql = <<<FQL
    SELECT name, page_id FROM page WHERE page_id IN (
      SELECT page_id FROM page_admin  WHERE uid = me()
    )
    FQL;
    
    // Get results from API
    $pages = $facebook->api('/fql', array('q' => $fql));
    
    // Collect pages for later usage by ID
    $pagesByIds = array();
    foreach($pages['data'] as $page){
        $pagesByIds[$page['page_id']] = $page;
    }
    
    // Query DB for all pages that exists in results
    $pagesIds = implode(',', array_keys($pageByIds));
    $res = mysql_query("SELECT page_id FROM pages WHERE page_id IN ({$pageIds})");
    
    while($pageRow = mysql_fetch_assoc($res)){
      $pageId = $pageRow['page_id'];
    
      // Remove pages that present in API results and DB
      if (isset($pagesById[$pageId])) unset($pagesById[$pageId]); ;
    }
    
    // Display details for pages not existing in DB
    foreach ($pagesByIds as $page){
      echo "ID: {$page['page_id']}, Name: {$page['name']} \n"
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using following code to get all the pages of pages WCF Service:
I'm currently using the following PHP code: // Get all subordinates $subords = array();
I'm using the following code to get an array with all sub directories from
All, I'm using the following code to get all of the defined wordpress menus
I'm trying to use the following code to get all trace data for the
i have the following code def get(self): date = datetime.date.today() loc_query = Location.all() last_cursor
Why does the following code get the runtime error: Members of the Triggers collection
I have the following code: // GET: /PlayRoundHole/Create public ActionResult Create(int id) { DB
In the following code I get a segmentation fault: Set *getpar() {...} char function(...)
When running the following code I get no output but I cannot work out

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.