Page 1 of 1

[Solved] Different content but same page

Posted: Wed Nov 12, 2003 11:24 am
by whizzy
Hi,

Sorry if I have posted in the wrong forum here guys... Kind of new to all of this, but have a hunger to learn.

My Question is this...

I have seen many php pages/sites that a link is supplied to for instance index.php , then there is a link to index.php?gid=uk to view a UK version of the site, followed by an index.php?gid=us to view a US version of a site.

How is this achieved? is there a tutorial somewhere I could follow? Having done all my learning on html, I really feel that a lot of it should have really been concentrated on PHP and MySQL as it is so more flexible.

Thanks for any help in advance.

Whizzy :)

Posted: Wed Nov 12, 2003 12:24 pm
by Johnm
This is done by having different include files for different conditions. Using a switch statement (case statement) is a good way to do this.

Code: Select all

<?php
switch ($gid)
{
    case "uk":
        include("uk.php");
        Break;
    case "us":
        include ("us.php");
        break;
    default:
        include ("us.php");
        break;
}

?>
So, when you post back to the same page and change the $gid different content is loaded. Make sense?

John M

Posted: Wed Nov 12, 2003 12:46 pm
by gite_ashish
If u r looking for "Language" versions, then it can also be done by having file names like --

index.php.en -- English language ver
index.php.fr -- French language ver
index.php.ru -- Russian language ver

pls see "AddLanguage" directive in httpd.conf (Apache config file) for details on how this 'works' with Apache web server.

NOTE - all the above details are regd Apache web server, not sure u r using Apache or somethig else.


BUT if u r talking about "Geographical Location" version of the web site, then thats a different story. For that, the web server (hardware box) itself is hosted in that country for faster access, and (generally) the site names are like --

us.website.com -- server hosted/located in US
uk.website.com -- server hosted/located in UK


hope this helps.

Posted: Wed Nov 12, 2003 2:54 pm
by whizzy
Thanks for the tips... In fact JohnM hit the nail on the head and that was exactly what I was looking for.

Thank you very much :)