0

Hi

I have a database of information and the code to get that data out of the database based on the url, it will be some like www.website.com/thekooks and then will display the information in the database for them.

The bit I am struggling with is where do I put the code? I do not want to create a page for every entry and I think there is a way to do it but I don't even know what to search for in google.

Can any tell me how to do this, or at least what I am looking for?

Thanks

2
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by phorce
0

Hey =)

I'm going to suggest a way (I think the way you want to do it, it is possible but with some .htaccess)

Basically, your URL would be something like:
- www.thesite.com/artists.php?name=thekooks
OR
- www.thesite.com/artists.php?id=1

and then you'd have a script that looks something like this:

<?php
	$name = $_GET['name'];
	
	echo $name; // This will output what's after the "=" in this case, thekooks
?>

BUT if you want to fetch data from a database, you could do something like this:

<?php
	$name = $_GET['name'];
	// connection information
	$query = "SELECT name ... FROM artists WHERE artist='$name'";
	$result = mysql_query($query);
	if(mysql_affected_rows() >= 1)
	{
		// display the results
		
	}else{
		echo 'No such band!';
	}
?>
0

Thanks, so do I then create a artist.php page, and then edit hta access so that the script on that page is executed anytime it appears in the url?

0

Sorry, that was my fault ;)

You'd create your artist.php and insert your code into it.

ONLY edit .htaccess if you want to have such a url like www.site.com/artists/thekooks/ (I believe this is how you get urls like this, but i'm not too sure) =)

So basically, every time the artists.php is ran, it will execute that code!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.