City Specific Website

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
kalpesh
Forum Commoner
Posts: 54
Joined: Sun Sep 21, 2008 5:04 am

City Specific Website

Post by kalpesh »

Hi, I am just trying my site to be city specific for user to select a specific city.
I see lot of sites which are city specific but what I found is two things.
First :- They make pages for every city individually.
Second :- In other sites when i select city in textbox url in page change to something like this.
First it has url like this:http://www.example.com/index.php
After select it has like this : http://www.example.com/Newyork/index.php
The contents are same but it has fetch contents by city.

In second case i think they only rewriting url.
But they are using same page as main index.php or they create page for City which only fetch contents citywise which is found in url.Thats something i didn't understand.


I have in database some tables which has column city.I don't want to change database structure.
I don't want to create new tables for city specific.

So how can i approach to this problem.
What is the optimized solution for this problem?
Please help me
Thanks in advance.
User avatar
sergio-pro
Forum Commoner
Posts: 88
Joined: Sat Dec 27, 2008 12:26 pm

Re: City Specific Website

Post by sergio-pro »

Hi

You can make it like this:

Code: Select all

 
    $uri = $_SERVER['REQUEST_URI'];
    //Remove first slash
    if (strpos($uri, "/") === 0) {
        $uri = substr($uri, 1, strlen($uri)-1);
    }
    $split = split("/", $uri);
    if (count($split) > 1) {
        echo "City is: " . $split[0];
        //Fetch city-specific info here 
    } else {
        echo "No city";
        //Fetch general info here
    }
 
 
Post Reply