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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:44:56+00:00 2026-06-17T06:44:56+00:00

Is it possible to refresh a divs content only if new content is added

  • 0

Is it possible to refresh a divs content only if new content is added to the database?

I’m using this for “recent posts” that appear in the side menu.

Right now the div is set refresh every 10 seconds.

Is it somehow possible to check it a new post was added to the db and then add only that posts data to the div?

I’m using MySql, php and jquery to do all of this.

  • 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-17T06:44:57+00:00Added an answer on June 17, 2026 at 6:44 am

    YES IT IS POSSIBLE

    The below code will get the recent photos that has been added:

    1. AFTER THE TIMER.PHP WAS LAODED (or your wordpress blog page)
    2. AND ONLY AFTER A NEW PHOTO IS ADDED (you can use it for recent posts, comments, or anything)

    This can be used to create a live blog for example, where the user will see all the recent comments, images or posts, or everything, even if he doesn’t reload the current page. And it won’t consume a lot of bandwidth as the content will be reloaded ONLY IF THERE IS NEW ADDED (it will only send a tiny check in the database otherwise).

    I’ve just finished working out a solution for that, and I have to share it with you. I was doing it for WordPress, i needed a function that gets the photos that has been added ONLY after the user loaded the page. It could be done by simply refreshing the div every 5 seconds, but imagine if there were 20 photos, and they had to be refreshed every 5 seconds… that’s a lot of MB of data. So we will refresh them ONLY when a new photo is added (you can apply it to anything, from posts to comments or users, etc.).

    There are 3 PHP files: timer.php, check.php and display.php.

    The timer.php will load the check.php every 5 seconds, to check if new content is added. Notice the -6 extraction from the time of the current load of check.php.

    The date-time of the timer.php will be passed (by check.php?tim=**print date) through the check.php (by **display.php?timm=’. $tizz .’) and to the display.php, so we can use it for a reference in our database (that will be the time from where we will load all the images, if new images are added).

    If any questions, just ask. It has to work for you too, as it works for me.

    ENJOY! 🙂

    Below are the 3 PHP files, just customize them for your needs:

    THE TIMER.PHP (or your wordpress blog pages):

    <script type="text/javascript" src="jquery.js"></script>
    
    <script type="text/javascript">
            $(document).ready(function(){
    
    
                setInterval(function(){
                    $("#quotex a").load("check.php?tim=<?php print date("Y-m-d H:i:s"); ?>");
                }, 5000);
    
            });
            </script>
    
            <div id="quote"><a></a></div>
    
    
            <div id="quotex"><a></a></div>
    

    THE CHECK.PHP :

     <?php 
         // Connects to your Database 
         mysql_connect("localhost", "username", "password") or die(mysql_error()); 
         mysql_select_db("database name") or die(mysql_error()); 
    
    
    
         // SQL query
            $strSQL = "SELECT * FROM wp_posts WHERE   post_mime_type LIKE 'image/jpeg' ORDER BY `wp_posts`.`id`  DESC LIMIT 1";
    
            // Execute the query (the recordset $rs contains the result)
            $rs = mysql_query($strSQL);
    
            // Loop the recordset $rs
            // Each row will be made into an array ($row) using mysql_fetch_array
            while($row = mysql_fetch_array($rs)) {
    
            $atime = $row['post_date'];
    
        $tizz = $_GET['tim'];    
    
        $dsff = $row['post_date'];;
    
        $duff = date("Y-m-d H:i:s");
    
        //convert the date-time into seconds so we can extract 6 seconds from it
        $six = strtotime(date("Y-m-d H:i:s"))-6; 
    
        //convert the latest image date-time too from database so we can compare it
         $sox = strtotime("$dsff");
    
         if ($six < $sox)
          {
          echo '<script type="text/javascript">$(document).ready( function(){ $("#quote a").load("display.php?timm='. $tizz .'"); } ); </script>';
          }
              }
    
            // Close the database connection
            mysql_close();
    
    
         ?>
    

    THE DISPLAY.PHP:

    <?php 
    $tipp = $_GET["timm"];
     // Connects to your Database 
     mysql_connect("localhost", "username", "password") or die(mysql_error()); 
     mysql_select_db("database name") or die(mysql_error()); 
    
    
    
    
     // SQL query
        $strSQL = "SELECT * FROM wp_posts WHERE   post_mime_type LIKE 'image/jpeg' AND post_date > '$tipp' ORDER BY `wp_posts`.`id`  DESC LIMIT 10";
        // Execute the query (the recordset $rs contains the result)
        $rs = mysql_query($strSQL);
    
        // Loop the recordset $rs
        // Each row will be made into an array ($row) using mysql_fetch_array
        while($row = mysql_fetch_array($rs)) {
        //guid is the column where the image url is located in the wordpress database table
        $atime = $row['guid'];
    
         echo "<img src='". $atime ."' /><br />";
          }
        // Close the database connection
        mysql_close();
    
    
     ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to refresh only one entity in entity framework designer? Every time
Possible Duplicate: Prevent any form of page refresh using jQuery/Javascript how can i prevent
Is it possible to refresh parent page from child's child page using javascript. I
Is it possible to refresh only the part of the page? How? the part:
Possible Duplicate: How to prevent duplicate posts via a browser refresh? I have a
I don't know if this is possible but I'd like to refresh the contents
Using javascript possible understood if page is load witch refresh button or F5 key?
I'm using jquery UI drag-and-drop. It is possible to refresh the div contents when
How to refresh a div content generated by the same php page using jquery
Is it possible to refresh part of the DOM via jQuery? I'm using drag

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.