I found a tutorial and im looking to create my own website like pandora in html5 or ajax for my country (or at least that's my plan).
The tutorial explains almost everything except 3 things: how to make the songs to not repeat if they have already been played, how to show the album art of the picture and play songs according to categories (like pop, rock, hip hop, etc).
I've looked through the tutorial rather quick, but i might have some plans to achieve your goals. Just to start with the easy one, album covers. When you create a database, you could add another field, like coverSrc, containing the link to the right cover In your HTMl, i'd create a DIV that will soon hold your album art. i would recommend giving the div a pre-defined width and height, to prevent it from resizing all the time if the size of your covers differ.
In your PHP file, you should also get that new field, and put it in a variable. let's call it $cover for eases' sake.
one of the functions in your JScript file would then have this code:
I didn't test this though, but maybe it gets you on the right track
Oh, and when you have a bigger database, it is probably better to use a albumID instead of an url, and then have a seperate database containing the name and cover source of the album. If you don't plan on making this a huge application, i'd say this is unnecessary.
playing by catogory: To play by category, you'll need another field in the database called... category. second, you'll need a dropdown list containing all the categories. make sure you only list the ones that you actually have in your database, else you would just get an error message.
in PHP this'd be:
$song = $db->get_row("SELECT * FROM songs WHERE category=" . $_POST["cat"] . " ORDER BY RAND() LIMIT 1");
$song = $db->get_row("SELECT * FROM songs ORDER BY RAND() LIMIT 1");
In english if your user wanted a specific category, select a row where the category is... well, whatever the user wants :) or else execute the piece of SQL you already had.
Once again, this isn't tested.
Unfortunatly, i can't think of any easy method for repeat protection, i guess waiting for someone else to react here, or asking the author of the tutorial for help.
Sorry for the long post, and if it seems a bit confusing, teaching is not exactly my speciality :)
i just got the album working: you'll need a new map to hold the images, and a new column in you table containing the link to the album (in my case, the column "album" had as content "albums/youralbumhere.png")
in getsong.php, add a single variable for the album, just as we have it for the title, and in the final echo we'll need another seperator and add the variable for the album
and in you main page, add a div that holds the album cover, give it an id (like album). Finally, in the JScript, use $("#youralbumdivid").html() to add the album's image. Do note that you'll have to insert more then plain text (like the other rows that look the same) but you'll have to insert some html. so ( "<img src=' + "string" + "'>" )
try it out now, if it doesn't work, i'll include my code. one note: i want to do as much as possible without external libraries, so i didn't use ezsql in getsong.php. but only some "classic" sql. getsong.php