PHP Search Form

I have figured out the basics of creating a search bar, but I really want to try to enforce my knowledge. I am trying to create a website with a database of artists and reviews and stuff like that. When I create my search I want it to search my database and then return with the particular path to that artists page. Something like www.musicuonline.com/artists/coldplay, without showing a results page beforehand. Is there something in php that will allow me to execute this?

I know that the question may sound a little confusing, and I totally a beginner on this stuff and am self teaching myself web design, so I probably don’t even know what I am talking about or if it even possible. I have it set up now and you can see it if you go to www.musicuonline.com but if you look into the url up top you will see the mess of stuff that brings you to the results page. Try a search for “crossfade” since it is the only artists I have fleshed out a little in my database. Just wondering if there is a way to clean that up.

For example, if you had a field for the name of the artist, you could search through the database and then relocate the user to that page.

To redirect a user, you can use:

header('Location: http://some-site.com/some/page');

To test for an exact match of the artist name, you would use a query similar to:

[php]$artist_query = mysql_query(‘SELECT FROM artists WHERE artists.name=’ . $artist_name . ‘;’);[/php]

Then check for it and generate the link:

[php]if(mysql_num_rows($artist_query) == 1)
{
header(‘Location: http://some-site.com/artists/’ . $artist_name);
}[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service