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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:49:19+00:00 2026-06-12T09:49:19+00:00

So here is the situation. I’m building a page to host a radio stream

  • 0

So here is the situation. I’m building a page to host a radio stream hosted on an Icecast server. I got the player working great and cobbled together a PHP script to extract and parse out various data points from the server. Information such as current track, number of listeners, etc.

Here’s the problem. It loads fine when the page is first opened, but I can’t figure out a way to get these variables to be updated every 5-10 seconds or so and update the page with the new information WITHOUT reloading the page completely (it is a radio station after all, and having to re-buffer the station ever 10 seconds just isn’t feasible.

Here’s what I have so far, after various attempts have been removed from the code. Any ideas? I’ve seen it done for one or two variables, but I have almost a Dozen here…

            <div id="current_song"></div>

            <script language="javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script> 
            <script language="javascript"> 
            {
              $.ajax({
                type: 'POST',
                url: 'script.php',
                data: 'getLatestInfo',
                dataType: 'json',
                cache: false,
              success : function(dp){
                $.getJSON('script.php', function(dp) {
            //'data' will be the json that is returned from the php file
                $.("#current_song").html("dp[9]");
            });
               getlatest();
              };
              });
            }
            </script> 

and here is the PHP parser

<?php 
Function getLatestInfo() {

$SERVER = 'http://chillstep.info:1984'; 
$STATS_FILE = '/status.xsl?mount=/test.mp3'; 
$LASTFM_API= '27c480add2ca34385099693a96586bd2'; 

//create a new curl resource 
$ch = curl_init(); 

//set url 
curl_setopt($ch,CURLOPT_URL,$SERVER.$STATS_FILE); 

//return as a string 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 

//$output = our stauts.xsl file 
$output = curl_exec($ch); 

//close curl resource to free up system resources 
curl_close($ch); 

//loop through $ouput and sort into our different arrays 
$dp = array(); 

$search_for = "<td\s[^>]*class=\"streamdata\">(.*)<\/td>"; 
$search_td = array('<td class="streamdata">','</td>'); 

if(preg_match_all("/$search_for/siU",$output,$matches)) { 
   foreach($matches[0] as $match) { 
      $to_push = str_replace($search_td,'',$match); 
      $to_push = trim($to_push); 
      array_push($dp,$to_push); 
   } 
} 
$x = explode(" - ",$dp[9]); 

echo json_encode($dp);
}
 ?>

I know it doesn’t look pretty yet, but that’s what CSS is for right?

Any ideas? Essentially I need the PHP script to rerun, update the variables, and rebuild the text output without touching the audio tag.

  • 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-12T09:49:20+00:00Added an answer on June 12, 2026 at 9:49 am

    Javascript is code that executes client-side (on the website visitors machine) and PHP executes serverside. The way to insert content into a page without reloading the entire page is to use Javascript to inject code into the HTML. Now, for example, say that you have a PHP file on your server, called getLatest.php with a function called getLatestVariables() that finds out the latest values for all your variables and returns an array containing them. What you can do is use javascript to call getLatestVariables() from getLatest.php, and when the function returns the array, it will return it to the javascript. Once the array of variables has been returned to the javascript you can then insert the variabes into HTML divs without having to refresh the entire page.

    to call the php function I suggest using jquery to perform an ajax call
    also to insert the data returned from the php, jquery is your best bet too.

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

Sidebar

Related Questions

I got myself in some kind of chicken-egg situation here. I have a page
SQL Server 2008: I've got a situation here in which I wish to read
I got a little confusing situation here when I use the Context from django.template.
Got a little situation here where I am trying to cancel a file's upload.
i got a tricky situation here. im trying to center 3 divs inside my
I have an interesting situation here. I am building a board game and I
Here my situation : The user click on a LinkButton, and the page does
I've got a weird situation here; I developed an app in 2011 using a
My situation here is that, I have asp Imagebuttons on my web page which
A simple situation here, If I got three threads, and one for window application,

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.