Page 1 of 1

Getting url adress into code?!?

Posted: Fri May 18, 2007 11:00 am
by jmansa
Hi. I'm trying to make my db call depending on the urladress.
I have a url adress like this:
Now I want to get "marion-city" into my script here:

Code: Select all

mysql_select_db("mydb", $con);$result = mysql_query("SELECT * FROM city WHERE cityurl=marion-city");
I want the script to be dynamic so if the cityurl is another it comes into the script automatic. I know it has something to do with "urlencode" but I dont know how?!?!? Please help!

Posted: Fri May 18, 2007 11:03 am
by Oren

Posted: Fri May 18, 2007 11:13 am
by jmansa
For this I need more exsplanation???

Posted: Fri May 18, 2007 11:25 am
by Grim...
Not really - you need strpos() to get the position in the string of the text you are looking for, then substr() to get it out.
Read through the pages that Oren linked to.

Posted: Fri May 18, 2007 12:06 pm
by volka
You can pull the info from $_SERVER['PATH_INFO'] and split the parameters with explode('/', $_SERVER['PATH_INFO'])
see http://de2.php.net/explode and http://httpd.apache.org/docs/2.2/mod/co ... ptpathinfo

Posted: Fri May 18, 2007 12:45 pm
by feyd
basename() may also be of use here.

Posted: Fri May 18, 2007 1:31 pm
by arturm
you can use mod_rewrite in apache to take care of SEO urls