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

The Archive Base Latest Questions

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

When a user on my site visits their profile page, they are met with

  • 0

When a user on my site visits their profile page, they are met with a list of posts they have made. I currently show 20 posts by default, but have no way of showing older posts. I would like to add a show more posts button that will load additional/older posts onto the page. What should i do to display more posts to the user after they click the show more button?

Here is my show posts function

function show_posts1($userid){
$posts = array();
$sql = "SELECT p.body, p.stamp, p.id,u.username, u.imagelocation 
    FROM posts p 
    INNER JOIN users u 
    ON p.user_id=u.id 
    WHERE p.user_id='$userid' 
    ORDER BY p.stamp DESC";
$result = mysql_query($sql);
while($data = mysql_fetch_object($result)){
    $posts[] = array(   'stamp' => $data->stamp, 
                        'userid' => $userid, 
                        'body' => $data->body,
                        'username' => $data->username,
                        'imagelocation'=>$data->imagelocation,
                        'id'=>$data->id
                );
}
return $posts;
}

Here is how i display the posts on the page

<?php
$posts = show_posts1($_SESSION['user_id']);
if (count($posts)){
?>
    <table>
<?php
        foreach ($posts as $key => $list){
            echo "<tr>";
            echo "<td>".$list['body']."
                 </td>";
            echo "</tr>";
        }
?>
    </table>
<?php
}else{
?>
    <p><b>You haven't posted anything yet!</b></p>
<?php
}
?>
  • 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-01T17:27:57+00:00Added an answer on June 1, 2026 at 5:27 pm

    Your query should look like this to paginate your results

    $sql = "SELECT p.body, p.stamp, p.id,u.username, u.imagelocation 
        FROM posts p 
        INNER JOIN users u 
        ON p.user_id=u.id 
        WHERE p.user_id='$userid' 
        ORDER BY p.stamp DESC
        LIMIT <offset>,<max_rows>";
    

    Store the current offset in Javascript and then just use AJAX to call show_posts1 ($userid[, $offset]) to run the query again and retrieve the next 20 posts.

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

Sidebar

Related Questions

Each user of my site has their own profile page, which contains several items
I have my user-based site set up as follows: Each user has their own
Whenever a user visits Page A on my site, I immediately redirect him to
When the user visits the site, I can get their country code. I want
When a user signs up for my site they enter their weekly availability in
When a user visits our site they see a coverflow. They are not logged
A typical browser based user visits site (A), then links to some sub page
I have users fill out their profile information somewhere on my site using the
i have a doubt in sessionid. when user visit the site one sessionid will
The following message is shown on everything page of a Drupal site: user warning:

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.