/    Sign up×
Community /Pin to ProfileBookmark

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) [url]www.example.com/gl/[/url] (Global English version)
2) [url]www.example.com/gb/[/url] (UK version)
3) [url]www.example.com/kz/[/url] (Kazakh version)
4) [url]www.example.com/eg/[/url] (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 [B][I][U][SIZE=4]include [/SIZE][/U][/I][/B]to get the data

[B][I][U]for example : in gl:[/U][/I][/B]

[code=php]

$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’);
[/code]

[B][I][U]and in gb[/U][/I][/B]

[code=php]
$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’);
[/code]

etc…………..

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

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@tishetskyAug 01.2013 — 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 putRewriteEngine On
RewriteRule index.php - [L]
RewriteRule ^([a-z]{2})/(.*) /index.php?lang=$1&amp;$2


Then in your script you set$lang = $_GET['lang']
and query the DB as $sql = "select stuff from tablename where lango = '{$lang}'";
This is to show you the common idea how to proceed.
Copy linkTweet thisAlerts:
@rootAug 01.2013 — 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.
×

Success!

Help @john_zakaria spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...