defeated Posted April 1, 2008 Share Posted April 1, 2008 Hi, Is it possible to use the $_Get function with the base of the url of a page? I want to have a dynamic <head> based on the url of the page.... something like $page=$_GET['url']; if($page='http://www.jackiebrownmedical.ie'){ echo "<title>the homepage</title>"; //there will also be other tags here eg description, robots etc. } elseif($page='http://www.jackiebrownmedical.ie/jobdetails.php'){ $id=$_GET['id']; echo "<title>more php that created a title for each page based on the job id</title>"; //there will also be other tags here eg description, robots etc. } else {echo "<title>a default title</title>";} The site structure is like this: http://www.jackiebrownmedical.ie //homepage http://www.jackiebrownmedical.ie/about.php //Static page http://www.jackiebrownmedical.ie/jobs.php //Static Page with dynamic content http://www.jackiebrownmedical.ie/jobdetails.php?id='123456' //dynamic pages based on job id no. every <title> is different (dynamic based on details from db) http://www.jackiebrownmedical.ie/applyform.php?id='123456' //dynamic form based on job id no. I cant just have www.jackiebrownmedical.ie?url='home' www.jackiebrownmedical.ie/about.php?url='about' www.jackiebrownmedical.ie/jobs.php?url='jobs' www.jackiebrownmedical.ie/jobdetails.php?url='jobdetails', id='123456' Or can I????? I need a genius to help me out here....... or failing that you'll do! Quote Link to comment Share on other sites More sharing options...
mikefrederick Posted April 1, 2008 Share Posted April 1, 2008 The get variable consists of what comes after the ? in the URL. So: $page=$_GET['url']; if($page=='about') { run commands; } elseif($page=='jobs') { more commands; } etc. Notice also that I used == and not =. Quote Link to comment Share on other sites More sharing options...
defeated Posted April 1, 2008 Author Share Posted April 1, 2008 can I put multiple items after the '?' ??? eg. www.jackiebrownmedical.ie/jobdetails.php?url=jobdetails, id='123456' ??? Quote Link to comment Share on other sites More sharing options...
jibster Posted April 1, 2008 Share Posted April 1, 2008 Yes you can except not like that. Like this instead: www.jackiebrownmedical.ie/jobdetails.php?url=jobdetails&id=123456&thisvar=thisvalue etc. Quote Link to comment Share on other sites More sharing options...
defeated Posted April 1, 2008 Author Share Posted April 1, 2008 Cheers Jibster.... that's all I need to know!..... for now anyway Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.