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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:57:56+00:00 2026-05-13T12:57:56+00:00

i am using this to collect comments made abt a particular user. i want

  • 0

i am using this to collect comments made abt a particular user. i want to display 7 comments on each page and want to enable pagination.
what would be the steps of implementation. sorry. n00b question.

$query = "SELECT msg, user_id, comment_time FROM comments WHERE aid = '$aid' ORDER BY comment_time DESC";
        $result = mysql_query($query) or die("ERROR: $query.".mysql_error());
        if (mysql_num_rows($result) > 0) {
            while($row = mysql_fetch_object($result)){
                $uidval = $row->user_id;
                if ($uidval != 0){
                $userInfo = $facebook->api_client->fql_query("SELECT name, pic_square_with_logo, profile_url FROM user WHERE uid='".$uidval."'");

            //  echo '<br>Array Info<br>';
            //  print_r($userInfo);
            //  echo '<br><br>';

                $nameuser = $userInfo[0]['name'];
                $pic = $userInfo[0]['pic_square_with_logo'];
                $profile_url = $userInfo[0]['profile_url'];

                echo '<img src="'.$pic.'" />';
                echo '<a href="'.$profile_url.'">'.$nameuser.'</a>';
                echo '<br>';
                echo $row->comment_time;
                echo '<br>';
                echo $row->msg;
                echo '<br>';
                }

            }
        }
  • 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-05-13T12:57:56+00:00Added an answer on May 13, 2026 at 12:57 pm

    The solution is best achieved via SQL’s limit/offset clauses. For MySQL, this is achieved via appending LIMIT [offset] [count] to your query. PostgreSQL uses separate select ... LIMIT [count] OFFSET [offset] syntax.

    The idea is you limit the number of results returned to the actual number you want to display. It can yield a huge performance increase if you’re displaying page 1 of 200, with a hundred results per page.

    Of course, you need to run a second query – a select count(*) from ... to determine the number of results in the result set. Divide this by the number of results per page, and you’ve got the number of pages.

    You will likely want to pass a page parameter in the query string, something like

    http://mysite.com/index.php?page=7
    

    and then pull the data using a similar method (consider this pseudo code; I know I’m not actually querying properly)

    <?php
    
    $num_per_page = 20; // 20 results per page
    
    $page = isset($_GET['page']) ? $_GET['page'] : 0; // start from page 0
    
    // Build our big query minus the SELECT part here
    $from_part = 'tbl_results [where ...]"'
    
    $num_results = query("SELECT COUNT(*) FROM $from_part");
    
    // Use ceil to round upwards
    $num_pages = ceil($num_results / $num_per_page);
    
    // Cap the page a the last page
    if ($page > $num_pages)
      $page = $num_pages;
    
    // Cap the page at the first page
    if ($page <= 1)
      $page = 1;
    
    $offset = $page * $num_per_page;
    
    // Build the final query to select the relevant page of data
    $results = query("SELECT * FROM $from_part LIMIT $offset, $num_per_page");
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using this page, http://developer.android.com/sdk/compatibility-library.html , I have installed the Android Support Package, added a
Using this piece of code in the head of a page: <script type=text/javascript> function
I'm using this drop down menu for my associations: <%= select(price, product_id, Product.all.collect {|p|
When I collect values from an array, I like using this ruby idiom: users.collect
I'm using the Facebook Comments social plugin and I want to be able to
Currently, I am using this function get indicies to collect the key/values from an
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
Using this to load the json var jsonParsed = JSON.parse(localStorage.getItem('test')); Using this to save
Using this C# application pick a start and ending date range, that SAP will
Using this tutorial: http://www.c-sharpcorner.com/uploadfile/UrmimalaPal/creating-a-windows-phone-7-application-consuming-data-using-a-wcf-service/ I have created sample/hello world application on the windows phone

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.