How can i make Database BASE Audio site?

I have a website and i want to add music section there so that i can do that manually but i want to do that with PHP and MySQL so my plan is : In my database i have 4 things those are ARTIST , ALBUM , SONGS NAME & DOWNLOAD LINKS. so on my Audio Index page i want to echo ONLY ARTIST NAME then if someone click on ARTIST name he will go another page and can see All Albums of That ARTIST and WHEN he click on Album Name he will see Songs name And Download Link . Please help me or give me any script location because i am not good in PHP and MySQL. Please give me MySQL structure and PHP script . Thank You in Advance. :slight_smile:

How much are you going to pay us to do all of this work for you? I hope you understand, WE ARE NOT A SOURCE OF FREE LABOR.

i didnt say like that bro but i wanted to know the concept :slight_smile: and if u know abt that then pls give me idea or if u know any source u can just suggest me :slight_smile:

thank you bro but its long term process and i am learning already but i am not fully professional … anyways thank you but i wanted to do that early so i posted but ur suggestions are helpfull :slight_smile: waiting for others if they will help me… God Bless you :slight_smile:

Hi anturj,

You would probably be better to do this more like a search page with the potential filters being Artist, Album, Song. Instead of having a user traverse 3 pages, you could set this up in one page as a form. Then use a traditional post on submit to carry the selected filters over to a PHP page that grabs the post values, connects to the database, runs an SQL query and then returns the result set back that is “ORDER BY” in a hierarchy based on the filters that are chosen. This is typically done where you’ve grab the $_POST values and then dynamically build the SQL query. Normally this is done like



$sql = "
SELECT 
  artist
  , album
  , song
FROM
  music
WHERE 
  1 = 1 ";

Now the 1=1 might be a little puzzling. This is done so you can append ‘AND’ statements after the 1=1 and no matter if any or one or more filters are chosen then the query will still run.

To test if filters exists, you would then do this:



if ($_POST['artist']) {
$artist = mysql_escape_string($_POST['artist']);
$sql .= "
  AND
    artist = $artist 
";
}
if ($_POST['album']) {
$album = mysql_escape_string($_POST['album']);
$sql .= "
  AND
    album = $album
";
}
if ($_POST['song']) {
$song = mysql_escape_string($_POST['song']);
$sql .= "
  AND
    song = $song
";
}

The use of mysql_escape_string() is not encouraged as it is now recommended to use PDO or mysqli to prepare and bind values, however I have used this just to show that you need in some way to clean all input data including $_POST, $_GET, $_SESSION, even JSON and serialized data.

If your form filter fields use free-text rather than combo box selections then you can substitute the equal sign (=) for LIKE: i.e.


if ($song) {
$sql .= "
  AND
    song LIKE %$song%;
";
}

This will allow people to kind of know who the song name but don’t have the exact title so in this case it will match songs like whatever name they type in the song form field.

One other thing is that you may consider using a javascript library like jQuery to perform an AJAX $_POST. This has the advantage of simplifying implementing AJAX and you can POST and return a result set by using a callback that will for instance return the results in JSON format without reloading the page.

But see how you make out with the first idea and I hope this helps a little.

Regards,
Steve

its well bro and this will help for make search engine for songs but actually i wanted to know : let me discuss : Suppose i have i music index page and on that page only show all artists name. and those artists name look like a button. if someone click on any artist name he will go another page and can see that artists all albums, and all albums also look like a link so if users choose or click on any album and click then he will go another page and he will able to see all songs under the albums . i wanted to know abt this. Do u have any idea bro ? @ ServerStorm help me please .

Thanks in Advance dear :):cool: