I was wondering if anyone could tell me how I would approach building a music search engine using php and mysql. I have a design for my Music search engine which I did using html css on Dreamweaver and I have some mp3/audio files on my computer and all i need to know is how to insert/retrieve the audio files into/from the mysql database and play it on my search engine at the user's request. Please if anyone could point me in the right direction or recommend some useful resources that could help me i would very much appreciate it.

Also if there are free scripts that you could recommend that I could use that would be helpful aswell.

Recommended Answers

All 4 Replies

mysqli_query("SELECT * FROM musicListThingie WHERE trackTag LIKE '" . $_GET["tracknames"] . "'");

If you already know how to retrieve data, fetch them, display them, the query I provided above is actually all you need. Of course, you need to change this one-liner for couple things.

More about this here. These are called wildcards which are quite essential on your mission. They help you to decide how queries should be distiniguished (conditioning), which spaces should be filled etc.

Member Avatar for diafol

This seems like a general use case. Just the fact that you're using audio files instead of video, images or pdfs etc.

When you add (INSERT) a track to the DB:

  1. Use an upload form - upload to a certain directory
  2. Store the path in the DB, along with any other info

When you retrieve (SELECT), grab the path from the DB and place into a player or audio tag.

http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_audio_all

However, if you use a HTML5 tag, then you have to supply all the playable files or just MP3 - I think all browsers will play MP3.

Yh, I will contribute to diafol's contribution. One thing you must keep in mind that storing music tracks directly in the database is a bad practice. This can slow down you server and make the SQL datables unnecessary large in terms of file size.

Member Avatar for diafol

Perhaps it's obvious, be very careful about uploading mp3s, for which you may not have a licence, and allowing visitors to play them!
If you're doing this sort of thing, then it may be illegal. However, you can use 3rd party APIs to do this for you, like Spotify and EchoNest, which allow you to create playlists in your own pages.

EchoNest has some particularly nice search features. I dabbled a bit about a year ago, so it's probably changed a bit by now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.