tutorials:other:online_playlist_on_your_website_with_php_mysql
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorials:other:online_playlist_on_your_website_with_php_mysql [2014/08/14 09:17] – [Preparing the MySQL Server] tw | tutorials:other:online_playlist_on_your_website_with_php_mysql [2014/08/14 09:36] – [Retrieving the Data] tw | ||
---|---|---|---|
Line 43: | Line 43: | ||
===== Preparing PHP Receive Script ===== | ===== Preparing PHP Receive Script ===== | ||
+ | Step #2 is to create a PHP script that receives new logging entries from mAirList via HTTP GET, and saves them into the MySQL table. | ||
+ | |||
+ | The script should be " | ||
+ | |||
+ | Let's assume the script is called '' | ||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | $db = mysqli_connect(' | ||
+ | |||
+ | $artist = mysqli_escape_string($db, | ||
+ | $title = mysqli_escape_string($db, | ||
+ | |||
+ | mysqli_query($db, | ||
+ | </ | ||
+ | |||
+ | Don't forget to adjust the MySQL login data in the first line ('' | ||
===== 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 '' | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | As Base URL, enter the URL of the secret playlistlog.php script, e.g. http:// | ||
+ | |||
+ | 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 '' | ||
+ | |||
+ | Now run mAirList, start a couple of songs and watch how the '' | ||
===== Retrieving the Data ===== | ===== Retrieving the Data ===== | ||
+ | |||
+ | Once the data is in the '' | ||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | |||
+ | $db = mysqli_connect(' | ||
+ | |||
+ | $res = mysqli_query($db, | ||
+ | |||
+ | print "< | ||
+ | while (list ($starttime, | ||
+ | print "< | ||
+ | } | ||
+ | mysqli_free_result($res); | ||
+ | print "</ | ||
+ | </ | ||
+ | |||
+ | 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