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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:29:28+00:00 2026-05-14T22:29:28+00:00

I programmed a CMS that has a log of who has recently logged into

  • 0

I programmed a CMS that has a log of who has recently logged into the system. Presently, this data is fed into a jQuery UI tab via Ajax. I would like to put this information into a sidebar on the main page and load it via AJAX every 30 seconds (or some set period of time).

How would I go about doing this? Does the PHP response need to be JSON coded? I am fairly new to AJAX and JSON data.

Here is the PHP I am currently using to pull details from the users table-

<?php
$loginLog = $db->query("SELECT name_f, name_l, DATE_FORMAT(lastLogin, '%a, %b %D, %Y %h:%i %p') AS lastLogin FROM user_control ORDER BY lastLogin ASC LIMIT 10");
while ($recentLogin = $loginLog->fetch()) {
echo $recentLogin['name_f'] . " " . $recentLogin['name_l'] . " - " . $recentLogin['lastLogin'];
}
?>

Thanks!
UPDATE

Okay, this is what I have so far.. the part I’m stuck on is how to loop through JSON and enter it into the box. It works fine as long as I use just one result and assure it is not in [ ]’s. I’m just learning Ajax and JSON, for some reason it isn’t coming to me too easily.

Javascript –

$(document).ready(function(){

                function refreshUsers(){

                    $.getJSON('json.php', function(data) {

                            for (var i = 0; i < data.length; i++) {

                                $("#loadHere").html('<p>' + data.name + ' ' + data.lastLogin + '</p>');

                            }

                });

            }

                var refreshInterval = setInterval(refreshUsers, 30 * 1000);

                refreshUsers();

            });

What my PHP script outputs –

[{"name":"Joe Smith","lastLogin":"Fri, May 21st, 2010 08:07 AM"},{"name":"Jane Doe","lastLogin":"Fri, May 21st, 2010 07:07 AM"}]

Thanks!

  • 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-14T22:29:28+00:00Added an answer on May 14, 2026 at 10:29 pm

    PHP side, use json_encode().

    Client side, use $.getJSON():

    function refreshUsers(){
      $.getJSON(url, postData, function (data, textStatus){
        // Do something with the data
      });
    }
    
    // Keep interval in a variable in case you want to cancel it later.
    var refreshInterval = setInterval(refreshUsers, 30 * 1000);
    

    With these 2, you should have a lot to get started with. More than this, you’d be asking us to work for you 🙂

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

Sidebar

Related Questions

Anyone who has programmed with actionscript 3.0 has most certainly noticed its lack of
I programmed a script that should resolve multiple hostnames into ip addresses using Multithreading.
Having programmed through emacs and vi for years and years at this point, I
I have programmed a sub procedure that will be called in the main procedure
We have a CMS built on Java and it has Mozilla Rhino for the
Right now I've programmed a method for use in a swing program that is
We have custom cms that currently sits on a vendor's subdomain, such as cms.vendor.com.
I programmed a sketch that uses Minim with the Processing IDE. Everything is working
I programmed (C# .Net 3.5) a process to start when windows (XP) starts. This
I've always programmed in Java, which is probably why I'm so confused about 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.