www.webdeveloper.com
Results 1 to 3 of 3

Thread: folders with same language and design but different database query problem

  1. #1
    Join Date
    Sep 2008
    Posts
    206

    folders with same language and design but different database query problem

    dear everyone..
    i am developing a website that contains 4 folders (gl,gb,kz,eg) each folder related to different country and all the website data are in English language but the difference is in the MySQL query of database to get data according to the country

    1) www.example.com/gl/ (Global English version)
    2) www.example.com/gb/ (UK version)
    3) www.example.com/kz/ (Kazakh version)
    4) www.example.com/eg/ (Egyptian version)



    i don't want to add my files to the root of each folder to avoid the headache when changing css or anything in the website..

    i dont want to change everything in 4 folders, i want to change only one file and those changes to affect in each folder, i tried to put my files in the root of my project and in each folder i made include to get the data


    for example : in gl:
    PHP Code:


    $select_query1 
    "SELECT * FROM databaseo where page='about' and lango='gl'";
        
    //print "select_query1: " . $select_query1 . "<br>";
        
    $res_query1 mysql_query($select_query1)
        or die (
    "table error1: " mysql_error());
    $res_rows1 mysql_num_rows($res_query1);
    //echo $res_rows1;
    //$tr_res_query1 = mysql_fetch_array($res_query1);

    //or

        
    while ($tr_res_query1 mysql_fetch_array($res_query1))
        {
        echo 
    'result here<br>';
        
        }
    include(
    '../about.php'); 
    and in gb

    PHP Code:
    $select_query1 "SELECT * FROM databaseo where page='about' and lango='gb'";
        
    //print "select_query1: " . $select_query1 . "<br>";
        
    $res_query1 mysql_query($select_query1)
        or die (
    "table error1: " mysql_error());
    $res_rows1 mysql_num_rows($res_query1);
    //echo $res_rows1;
    //$tr_res_query1 = mysql_fetch_array($res_query1);

    //or

        
    while ($tr_res_query1 mysql_fetch_array($res_query1))
        {
        echo 
    'result here<br>';
        
        }
    include(
    '../about.php'); 
    etc..............

    but it did not work for me because of difference in paths for *.js files and for folders.. any idea????

  2. #2
    Join Date
    Jul 2013
    Posts
    29
    You do not have to keep separate scripts for each language if the only difference is in select conditions. In most general case you need one script and mod_rewrites that will pass language code as an argument to that script.

    In .htaccess you put
    Code:
    RewriteEngine On
    RewriteRule index.php - [L]
    RewriteRule ^([a-z]{2})/(.*) /index.php?lang=$1&$2
    Then in your script you set
    Code:
    $lang = $_GET['lang']
    and query the DB as
    Code:
    $sql = "select stuff from tablename where lango = '{$lang}'";
    This is to show you the common idea how to proceed.

  3. #3
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,407
    Well it does help if people understand the difference in paths for your .js files.

    As well as that, the difference in the JScript would be an advantage as you may have minor differences that can be addressed by making your javascript source path call a PHP file that delivers the appropriate javascript code.

    <script src="./some/path/to/javascriptcode.php?select={$lang}" ></script>

    where the PHP accepts a query value that tells that PHP script what language to deliver.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles