Hey guys,
So lately I have been working on a radio page for my community. It contains information which is echoed from a MYSQL DB, on to the page. This shows stuff such as song name, artist, latest songs played etc.
Some of this is displayed in tables. I have been looking around, and I can not find anything which is understandable for what I am looking for - I would like to be able to have the tables and song title / artist update automatically without refreshing the page. I guess that this would have to be done via AJAX or JS, but I can’t find anything helpful for it and wondered if any of you could work some magic and help me solve this.
Below is the data I am showing and how I am showing it:
Example of some PHP Data which is being shown:
[php]<?php
db_conn();
$query = “SELECT artist
, title, count(*) AS tracks FROM history
WHERE TIMESTAMPDIFF(DAY, date_played
, NOW()) <= " . $resDays . " AND song_type
=0 GROUP BY title ORDER BY tracks DESC LIMIT 0,” . $resLimit;
$result = mysql_query($query);
if (!$result) {
echo mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo “<div class=“noticediv”>No results found!”;
require_once(‘footer.php’);
exit;
}
$inc = 1;
while($row = mysql_fetch_assoc($result)) {
echo " <tr>" . "\n";
echo " <td>" . $row['artist'] . "</td>\n";
echo " <td>" . $row['title'] . "</td>\n";
echo " <td>". $row['tracks'] . "</td>\n";
echo " </tr>" . "\n";
$inc += 1;
}
@mysql_free_result($result);
db_close($opened_db);
?>[/php]
This PHP code is put inside a table, allowing it to be shown within the table. An example of the table is shown below:
So -
Does anybody know how I would go with this in terms of allowing the PHP Data to be updated/refreshed, without actually refreshing the page? In other words, “Live” data.
Thanks for any help,
Lewis.