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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:53:14+00:00 2026-05-25T05:53:14+00:00

Here’s my issue. I’ve tried many many things and realized I can cook an

  • 0

Here’s my issue. I’ve tried many many things and realized I can cook an egg on my brain right now. I need your help.

I need to add pagination on the div where the content is being posted. More specifically, paginate the lists from that are being generated by the users.

This is in my index.php:

<div id="head">
<form name="postbar_add_post" id="postbar_add_post" method="post">
    <fieldset>
        <legend>What are you doing now? ...</legend>
        <input type="text" name="addcontentbox" id="addcontentbox" maxlength="200" />
        <input type="submit" name="addpost" value="Submit" class="submit" />
        </fieldset>
</form>
</div>

<div id="cuerpo"><ul id="wall"></ul></div> 

When the text is submitted, it uses the following JavaScript code to post the data for that div:

// This is the script to post whats typed on the input to the div called wall:
<script type="text/javascript">
    $.noConflict();
    jQuery(document).ready(function() {
        jQuery("form#postbar_add_post").submit(function() {
            var addcontentbox = jQuery('#addcontentbox').attr('value');
            if (addcontentbox.replace(/\s/g,"") == "") {
                return false;
            }
            jQuery.ajax({
                type: "POST",
                url: "postear.php",
                data: "addcontentbox=" + addcontentbox,
                success: function() {
                    jQuery("ul#wall").prepend("<li>"+addcontentbox+"</li>");
                    jQuery("ul#wall li:first").fadeIn();
                    document.postbar_add_post.addcontentbox.value = '';
                    document.postbar_add_post.addcontentbox.focus();
                }
            });
            return false; 
        });
    });
</script>

I’m using $.noConflict(); because I already tried to paginate it with another jquery plug in called Jpagination.
Unfortunately, no good results. Click here if you want to check on that.

The previous Ajax code calls a PHP file to insert the message into a database.

This is the php code:

<?php
if(isset($_POST['addcontentbox'])) {
    // Connection to Database
    include('config.php');
    // NO Query Injection
    $message = mysql_real_escape_string($_POST['addcontentbox']);

    // echo
    $sql = 'INSERT INTO WALL (message) VALUES( "'.$message.'")';
    mysql_query($sql);
    echo $message;
}
else
{ 
    echo '0';
}
?> 

So, I tried to integrate pagination with PHP but I really got lost. Then I found some scripts online for pagination but that got me even worst.

So I really need help.

Can anyone tell me how could I add pagination to the unsorted list on the index.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-05-25T05:53:14+00:00Added an answer on May 25, 2026 at 5:53 am

    Well I’m still not 100% clear how you want this to function, but I have an idea. Let’s say you want to display 10 messages on a page. So when the page first loads, it will have the 10 latest comments.(You can do this by changing your SQL query a bit) You’ll also want your index.php to accept a page variable in the query string, so you know what page to load. like index.php?page=1.
    Then you can write your initial query to fetch the messages like this: (after doing this $page = $_GET['page'];

    "SELECT * FROM wall ORDER BY id DESC LIMIT $page*10, 10"
    

    besides fetching the latest messages, you’ll want to know how many message there are in total, so you know how many pages you have. You can get that with a sql query also.

    "SELECT COUNT(*) FROM wall"
    

    Now let’s go back to you html. after fading in the new posted message with jQuery("ul#wall li:first").fadeIn(); you can fade out the oldest message with jQuery("ul#wall li:last").fadeOut();

    To make a list of the pages, just divide the total number of messages by the number of messages per page to figure out how many pages you need. Then you can use a php for loop to echo out a bunch of links with the page numbers sort of like this.

    <? for($i=0; $i<$total_pages; $i++) { ?>
        <a href="index.php?page=<?=$i;?>"><?=$i;?></a>
    <? } ?>
    

    So when someone clicks on one of those links, it will re-load your page with the correct messages. Of course there is a lot more you can do with this, but I think this is the basic idea. I hope it helps.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
Here are the yammer api docs: http://developer.yammer.com/restapi/ Am I missing something here? How can
Here is my error(if you need any more info just ask)- Error SQL query:
Here the scenario is I have many .aspx pages if any page gives error,
Here's the situation, i want to have a user that can enter time on
Here is the scenario: I have several CIFS partitions which AD-based users can mount
Here's the view: @if (stream.StreamSourceId == 1) { <img class=source src=@Url.Content(~/Public/assets/images/own3dlogo.png) alt= /> }
Here's my code in the <head></head> : <link rel=stylesheet href=http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css /> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js></script>
Here is the code in a function I'm trying to revise. This example works
Here is the code: create table `team`.`User`( `UserID` bigint NOT NULL AUTO_INCREMENT , `Username`

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.