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

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!';
	}
?>

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?

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!

Ok brilliant, I'll give it a go. Thanks a lot

Just make sure you do checks on it, if your using $_GET, for sql injections etc =)

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.