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

The Archive Base Latest Questions

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

However since i am not too familiar with oop in php. i am not

  • 0

However since i am not too familiar with oop in php. i am not sure what i need to define the $db variable as, in order to query my database properly. Is their a way i can edit this code, so it sidesteps the $db and uses a different approach, the code is using ajax to load more posts. The error is on line 24

<html> 
<head> 
<script> 
$(document).ready(function(){ 
$("#loadmorebutton").click(function (){ 
    $('#loadmorebutton').html(''); 
$.ajax({ 
    url: "loadmore.php?lastid=" + $(".postitem:last").attr("id"), 
    success: function(html){ 
        if(html){ 
            $("ul#posts").append(html); 
            $('#loadmorebutton').html('Load More'); 
        }else{ 
            $('#loadmorebutton').replaceWith('No more posts to show.'); 
        } 
    } 
}); 
}); 
}); 
</script> 
</head> 
<body> 
<?php 
if($posts = $db->get_results("SELECT id,text FROM posts ORDER BY id DESC LIMIT 10")) { 
echo '<ul id="posts">'; 
foreach($posts as $post) { 
    echo '<li class="postitem" id="'.$post->id.'">'.$post->text.'</li>'; 
} 
echo '</ul>'; 
} 
?> 
<button id="loadmorebutton">Load More</button> 
</body> 
</html>

Load more

<?php 
if($_GET['lastid']){ 
if($posts = $db->get_results("SELECT id,text FROM posts WHERE id < ".$db-    >escape($_GET['lastid'])." ORDER BY id DESC LIMIT 10")) { 
    foreach($posts as $post) { 
        echo '<li class="postitem" id="'.$post->id.'">'.$post->text.'</li>'; 
    } 
} 
} 
?>
  • 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:22:16+00:00Added an answer on June 1, 2026 at 5:22 pm

    This is going to prove complicated if you are not used to Object Oriented PHP but you need to construct your objects. The MySQLi class constructor for instance, takes user, password, database, etc and then knows where it should connect to.

    Before you can use stuff like $db->get_results, you need to construct your DB object. Now I don’t recognize the get_results function so I presume it is a custom built DB class. You should see the documentation for that specific class if you want to know what to do.

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

Sidebar

Related Questions

I previously had a post on this issue that was resolved. However since rebuilding
I have been posting on my blog http://www.prashantraju.com/ since Jan 2010 however for some
PowerBuilder seems to have some support for plug-ins since version 10. However, I can't
All source files seem to have compiled fine. However, since I achieved that, I
I've been trying to use copytree(src,dst), however I couldn't since the destination folder should
Okay, it seems to be a stupid question, since we have this However, up
I installed TeamCity and got it working against my project. However, I have since
I want to use the Html.Encode by replacing Name <%=Html.TextBox(Name, Model.projectModel.Name)%> However, since i`m
I only have experience with log4net however that does not mean that there are
Every Windows developer is all too familiar with an alert of the form: Foo.exe

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.