Insert track via script - database id

Hello - my question here, also in english.

I am searching for a solution, to add songs from the database, identified from its database-id.

(example: adding the song with id number xxx to playlist as next Event).

Thanks for your help!

From my point of view, there’s no need to use the Database ID. Simply make an event, command “Insert file” and choose the location (path) of the file.

Insert item 12345 from database to the playlist, after the current item:

begin
  CurrentPlaylist.Insert(CurrentPlaylist.GetNextIndex, Database(0).CreatePlaylistItem('12345'));
end.

Thanks, it works wonderful. :slight_smile:

One more question:

(how) can i grab a variable from a php script?

Thanks for your help!!!

What kind of variable? In the URL? Is this a PHP question? Wrong forum :wink:

I assume you have read this?

https://www.mairlist.com/dokuwiki/tutorials:other:online_playlist_on_your_website_with_php_mysql

No, i think right forum.

I will catch an integer from a variable from an external site (php).

(http://example.com/example.php - in this file there is an variable like $example = ‘1234’; and now, i need to read out $example)
I hope i clearified what i mean
:wink:

Thanks

You mean, the PHP script is putting out a variable (writing it to the output)?

print $example;

You can use the HTTPGet function in mAirListScript to catch the entire output of an HTTP GET call:

var
  output: string;

begin
  output := HTTPGet('http://example.com/example');
end.

Note that this is a string - to convert to an integer, use StrToInt:

var
  output: integer;

begin
  output := StrToInt(HTTPGet('http://example.com/example'));
end.

Thanks for all, but I am to stupid, i think ;D ;D

So. I get a database id (generated by a user for requesting a song) from php (definitly from a mysql databse).
So - for then i need my php-variable ($example) (its the id of the song) in my script - to insert the song (depending on the id)
as next item in the playlist.

So maybe - you can help me again.
Thank you so much… :smiley:

begin
  CurrentPlaylist.Insert(CurrentPlaylist.GetNextIndex, Database(0).CreatePlaylistItem(HTTPGet('http://example.com/example.php')));
end.

And the PHP script simply prints the $example variable at the end:

print $example;

Thanks!
Thanks!!
And one more time: Thanks!