PHP/JavaScript and AJAX Demo

IDEA: I have a MySQL DB with some of the albums that I have in my music library. You can query this database below.

PHP Examples

 
Example 1: Click here to view the artists that I have in my collection.
Description:
  1. This link above calls the myMusic.php file with the parameters query=0. This indicates to the script that we want to run the general "get all album from collect" Database Query.
  2. The output of this is a table with the list of the artists that I have in my collect in a table, along with a description of that artist. The Artists name is actually a link to the same myMusic.php but this time the parameters are query=1&artist=XXXX where XXXX is the name of the artist that you just clicked on. This indicates that you want to run the more specific "get me the albums from this Artist" Database query.

AJAX Examples

 
Example 2:

My Music Collection:

Artists

Albums

 

Description:

The 2 sections above Artists and Albums both have arrows beside them to click on.

  1. If you click on the arrow beside Artists you will invoke the getMyArtists() JavaScript function which will call a PHP script to get the list of all the artists in my DB.
  2. If you click on the arrow beside Albums you will invoke the getMyAlums() JavaScript function which will call a PHP script to get the list of all the albums in my DB.
  3. When the albums are displayed you can click on the names of the albums to view the artwork or alternatively, click on the icon beside the album name which will invoke the getArtwork() JS function. This calls a PHP script which retrieves the artwork from the DB for the specified album clicked. It will dynamically update the existing page.

All of the above follow the AJAX - HTML calling JavaScript calling PHP responds to JavaScript dynamically updates HTML - method.