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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:14:30+00:00 2026-06-14T08:14:30+00:00

my sql table contain in row offline access token contain id column and access

  • 0

my sql table contain in row offline access token contain id column and access token i want to edit code to run $output for ids from 1 to 50 then a next button to run next 50 until all finished instead of run all in one time

   <?php

require './config.php';
require './facebook.php';

//connect to mysql database
mysql_connect($db_host, $db_username, $db_password);
mysql_select_db($db_name);
mysql_query("SET NAMES utf8");

//Create facebook application instance.
$facebook = new Facebook(array(
  'appId'  => $fb_app_id,
  'secret' => $fb_secret
));

$output = '';

//if form below is posted- 
//lets try to send wallposts to users walls, 
//which have given us a access_token for that
if(isset($_POST['send_messages'])){

    //default message/post
    $msg =  array(
        'message' => 'date: ' . date('Y-m-d') . ' time: ' . date('H:i')
    );

    //construct the message/post by posted data
    if(isset($_POST['message'])){
        $msg['message'] = $_POST['message'];
    }
    if(isset($_POST['url']) && $_POST['url'] != 'http://'){
        $msg['link'] = $_POST['url'];
    }
    if(isset($_POST['picture_url']) && $_POST['picture_url'] != ''){
        $msg['picture'] = $_POST['picture_url'];
    }

    //get users and try posting our message/post
    $result = mysql_query("
        SELECT
            *
        FROM
            offline_access_users
    ");

    if($result){
        while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
            $msg['access_token'] = $row['access_token'];
            try {
                $facebook->api('/me/feed', 'POST', $msg);
                $output .= "<p>Posting message on '". $row['name'] . "' wall success</p>";
            } catch (FacebookApiException $e) {
                $output .= "<p>Posting message on '". $row['name'] . "' wall failed</p>";
            }
        }
    }
}


?><!DOCTYPE html 
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="et" lang="en">
    <head>
        <title>Batch posting</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <style type="text/css">
            body { font-family:Verdana,"Lucida Grande",Lucida,sans-serif; font-size: 12px}
        </style>
    </head>
    <body>
        <h1>Batch posting</h1>
        <form method="post" action="">
            <p>Link url: <br /><input type="text" value="http://" size="60" name="url" /></p>
            <p>Picture url: <br /><input type="text" value="" size="60" name="picture_url" /></p>
            <p>Message: <br /><textarea type="text" value="" cols="160" rows="6" name="message" />Message here</textarea></p>
            <p><input type="submit" value="Send message to users walls" name="send_messages" /></p>
        </form>
        <?php echo $output; ?>
    </body>
</html>
  • 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-14T08:14:31+00:00Added an answer on June 14, 2026 at 8:14 am
    <?php
    
    require './config.php';
    require './facebook.php';
    
    //connect to mysql database
    mysql_connect($db_host, $db_username, $db_password);
    mysql_select_db($db_name);
    mysql_query("SET NAMES utf8");
    
    //Create facebook application instance.
    $facebook = new Facebook(array(
      'appId'  => $fb_app_id,
      'secret' => $fb_secret
    ));
    
    $output     = '';
    $isHaveNext = false;
    
    if (isset($_POST['send_messages'])) {
    
        //default message/post
        $msg = array(
            'message' => 'date: ' . date('Y-m-d') . ' time: ' . date('H:i')
        );
    
        //construct the message/post by posted data
        if (isset($_POST['message'])) {
            $msg['message'] = $_POST['message'];
        }
        if (isset($_POST['url']) && $_POST['url'] != 'http://') {
            $msg['link'] = $_POST['url'];
        }
        if (isset($_POST['picture_url']) && $_POST['picture_url'] != '') {
            $msg['picture'] = $_POST['picture_url'];
        }
    
        // get offset
        $offset = isset($_POST['offset']) ? intval($_POST['offset']) : 0;
    
        // get total rows count
        $query = mysql_query("SELECT COUNT(1) FROM offline_access_users LIMIT 1");
        $rows  = mysql_fetch_array($query);
        $total = $rows[0];
    
        //get users and try posting our message/post
        $result = mysql_query("SELECT * FROM offline_access_users LIMIT 50 OFFSET $offset");
    
        if ($result) {
            while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                $msg['access_token'] = $row['access_token'];
                try {
                    $facebook->api('/me/feed', 'POST', $msg);
                    $output .= "<p>Posting message on '" . $row['name'] . "' wall success</p>";
                } catch (FacebookApiException $e) {
                    $output .= "<p>Posting message on '" . $row['name'] . "' wall failed</p>";
                }
            }
        }
    
        // next
        if ( $total > ($offset + 50) ) {
            $isHaveNext = true;
            $offset += 50;
            ?>
            <form action="" method="post">
                <input type="hidden" name="message" value="<?php echo $_POST['message'] ?>">
                <input type="hidden" name="url" value="<?php echo $_POST['url'] ?>">
                <input type="hidden" name="picture_url" value="<?php echo $_POST['picture_url'] ?>">
                <input type="hidden" name="offset" value="<?php echo $offset ?>">
                <input type="submit" name="send_messages" value="Next">
            </form>
            <?php
            echo $output;
        }
    }
    
    if ($isHaveNext) exit(1);
    
    ?>
    <!DOCTYPE html 
        PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="et" lang="en">
        <head>
            <title>Batch posting</title>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <style type="text/css">
                body { font-family:Verdana,"Lucida Grande",Lucida,sans-serif; font-size: 12px}
            </style>
        </head>
        <body>
            <h1>Batch posting</h1>
            <form method="post" action="">
                <p>Link url: <br /><input type="text" value="http://" size="60" name="url" /></p>
                <p>Picture url: <br /><input type="text" value="" size="60" name="picture_url" /></p>
                <p>Message: <br /><textarea type="text" value="" cols="160" rows="6" name="message" />Message here</textarea></p>
                <p><input type="submit" value="Send message to users walls" name="send_messages" /></p>
            </form>
    <?php echo $output; ?>
        </body>
    </html>
    

    Bonus: Use PDO instead of mysql_* functions.

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

Sidebar

Related Questions

My sql table is something like (message,created) I want to select those rows which
i have some SQL code that is inserting values from another (non sql-based) system.
I have a SQL Server database table with a column called resources. Each cell
I have got the following table where if more than 1 row contain the
I am to displaying rows from a database (SQL SERVER 2005) table in a
I wrote this sql query to search in a table: SELECT * FROM TableName
I have a table with a column called ExcelLinks that contain records like this:
I've got a question regarding a SQL-select-query: The table contains several columns, one of
I have a table which contains my ads that can be searched in sql-server-2008.
I have a table in SQL Server called [Donations] that contains donations given by

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.