User Tools

Site Tools


tutorials:other:online_playlist_on_your_website_with_php_mysql

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
tutorials:other:online_playlist_on_your_website_with_php_mysql [2014/08/14 09:23] – [Preparing PHP Receive Script] twtutorials:other:online_playlist_on_your_website_with_php_mysql [2019/07/09 16:18] – external edit 127.0.0.1
Line 62: Line 62:
 ===== Setting up mAirList HTTP Logging ===== ===== Setting up mAirList HTTP Logging =====
  
 +We use HTTP GET to transfer new entries to the webserver, so go to //mAirList Configuration -> Logging//, click ''Add'' and add a new ''HTTP GET'' interface. The dialog will look like this:
 +
 +{{ :tutorials:other:pasted:20140814-112920.png?300x300 }}
 +
 +As Base URL, enter the URL of the secret playlistlog.php script, e.g. http://www.yourserver.com/playlistlog.php.
 +
 +In the Parameters table, add two parameters: //artist// with value //%a//, and //title// with value //%b//. **Use the cursor-down key to add more lines to the table.**
 +
 +That's pretty much it. If you protected your script with an ''.htaccess'' file, enter the user/password. If you only want particular item types to be logged (e.g. only music but no jingles), go to the //Item Types// tab and uncheck the types that should be filtered.
 +
 +Now run mAirList, start a couple of songs and watch how the ''playlistlog'' table is populated. If it doesn't work, it's a good idea to check the mAirList System Log for any error messages (double-click the status bar at the bottom of the mAirList main window).
 ===== Retrieving the Data ===== ===== Retrieving the Data =====
 +
 +Once the data is in the ''playlistlog'' table, you can use very simple PHP code to retrieve the last few songs:
 +
 +<code php>
 +<?php
 +
 +  $db = mysqli_connect('localhost', 'mairlist', 'secret', 'logdatabase');
 +
 +  $res = mysqli_query($db, 'SELECT starttime, artist, title FROM playlistlog ORDER BY starttime DESC LIMIT 10');
 +
 +  print "<table>\n";
 +  while (list ($starttime, $artist, $title) = mysqli_fetch_row($res)) {
 +    print "<tr><td>$starttime</td><td>$artist</td><td>$title</td></tr>\n";
 +  }
 +  mysqli_free_result($res);
 +  print "</table>\n";
 +</code>
 +
 +As all entries are stored along with the date/time the song was started, it is also possible to implement a search function that looks up the songs played in a given time frame.
  
tutorials/other/online_playlist_on_your_website_with_php_mysql.txt · Last modified: 2021/06/18 06:40 by tw

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki