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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:51:39+00:00 2026-06-08T14:51:39+00:00

i’m trying to auto retrieve data from mysql server in specific DIV without manual

  • 0

i’m trying to auto retrieve data from mysql server in specific DIV without manual refresh the web page.

My PHP code is:

function lastCodes(){
    include('mysql.php');
    include('config.php');

echo "<div id='content_data'>";

    $get = mysql_query("SELECT * FROM scripts ORDER by date_added DESC");
    if(mysql_num_rows($get)>0){
        while($row = mysql_fetch_assoc($get)){

            $get2 = mysql_query("SELECT * FROM accounts WHERE username = '$row[s_owner]'");
                while($red = mysql_fetch_assoc($get2)){

            echo "<table>
                        <tr>
                                <td width='22px'>";
                        if(!empty($red['avatar'])){
                            echo "<center>
                                        <img src='$red[avatar]' style='width: 52px; height: 52px; margin-left: -30px; border: 2px solid #fff;' title='$row[s_owner]'/>
                                    </center>
                                </td>";
                        } else {
                            echo "<td width='22px'>
                                        <center>
                                            <img src='/theme/$tema/icons/empty_avatar.png' style='width: 52px; height: 52px;' title='$row[s_owner]'/>
                                        </center>
                                    </td>";
                        }       

            echo "<td>
                        <a style='font-family: IndexName; color: #000; font-size: 14px; margin-left: 5px;'><b>$row[s_owner]</b> написа <a title='$row[s_name], Категория: $row[s_category].' href='#' style='text-decoration: none;'>нов код</a> <a style='font-family: IndexName; color: #000; font-size: 14px; margin-right: 10px;'>в $row[date_added]</a>
                    </td>
                    </tr>
                    </table>";

        }

        }

    }

echo "</div>";

}

What should be in my case the jquery/ajax code if I want to retrieve this information in DIV called “content_data” in interval of 5 seconds? Thanks a lot!

  • 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-08T14:51:42+00:00Added an answer on June 8, 2026 at 2:51 pm

    You could place the contents of your lastCodes() function inside an otherwise empty PHP file, let’s call it lastCodes.php.

    And then use the load function from JQuery on the page where you want to retrieve the data

    <div id="divTarget"></div>
    <script type="text/javascript">
        $("#divTarget").load("lastCodes.php");
    </script>
    

    But keep in mind that this way of coding can get messy real fast. I would recommend you to try any of the many great template systems available. It’s not necessary for clean code but without one you will need some discipline keeping logic out of your view code.

    And when you feel comfortable with one of those you could go even further and try a template system on the frontend using Javascript, for example Handlebars. With one of those you will be able to write clean code and send your data using JSON which will lower the size of the HTTP response and at the same time make the data more usable for other scenarios than simply rendering it as HTML.

    Edit: To update the data every 5 seconds:

    <script type="text/javascript">
      window.setInterval(function() {    
         $("#divTarget").load("lastCodes.php");
      }, 5000);
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.