I am not too sure what you mean.
So for example:
If somebody clicked on a domain.com/sitea it would use database a but if they used domain.com/siteb ?
You could use an if statement in PHP and either link it to the url or url variables.
Hi there, wonder if anyone can help me please.
Im creating a database driven site, understand how to create, select and place database info into a website where i need it etc.
What I dont get is how to make a database attached to a permalink/url. So, i have one Mysql connect code in a header and, depending what link has been clicked, it connects to a certain database and displays that information.
I Hope this makes sense and someone out there can help, thanks!
![]()
I am not too sure what you mean.
So for example:
If somebody clicked on a domain.com/sitea it would use database a but if they used domain.com/siteb ?
You could use an if statement in PHP and either link it to the url or url variables.
Kind of, but what im thinking of is i want one page which pulls in all the data required to build it, but wht data is pulled in depends on what link has been clicked. So, for example, i have an index page with a monkey link on it, if a user clicks on it then a new page is created from the database.
You'll query the database based upon values from the the request whether that be the page name/url or request parameters.
You'll use the results from the database query (or queries) to build the response.
Google php mysql example and you'll find 1000s of examples to get you started.
Nothing to see here
crumblepie1 (01-07-11)
OK so you want to make a new page based on the link?
So if you had a link for example domain.com/monkey-link/
crumblepie1 (01-07-11)
Hi,
Thanks for the help, i think im getting there now, but there must be a problem with my code somewhere:
My link says: http://www.sitename.com/whatever.php?link=blahblah
And i put the following code in the header :
<?php echo $_GET["link"];
mysql_connect("localhost", "name", "password") or die(mysql_error());
mysql_select_db("databasename") or die(mysql_error());
$link = $_GET['link'];
$row = mysql_query("SELECT * FROM $link"
or die(mysql_error());?>
For some reason i keep getting a syntax error, unexpected ";" on the last line, but even if i remove this i still get it, any ideas where im going wrong?
Err, scratch that, ive finally worked everything out, appreciate all the help though![]()
Use WordPress!!! and use custom pages (no need to do a db)
You need a database driven site with URL re-writing...
For example... using .htaccess re-writes you could have;
mysite.com/fruit/bananas.html <--which is displayed to the user but shows the content from;
mysite.com/products.php?productID=1234
Your SQL code then takes the productID $productID = $_GET['productID'];
And asks the database for the appropriate info
SELECT * FROM mytable WHERE id = $id
and you go from there![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks