Page 1 of 1

change btween tables...!

Posted: Sat Oct 03, 2009 3:25 pm
by egturnkey
Hello friends,

I have a problem which as follow


- if we do create 4 database tables says

en_m1
ar_m1

and

en_m2
ar_m2

now upon change the lang from en ( english ) to ar ( arabic )

will be that right for one table

Example ----->(1)<------

Code: Select all

 
if($lang == "en")
   $table_name="en_m1";
 
 
else if($lang == "ar")
   $table_name="ar_m1";
 
$q1 = "select * from $table_name";
$r1 = mysql_query($q1) or die(mysql_error());
$a1 = mysql_fetch_array($r1);
 
 



till now fine but how it could be done if we have 2 tables such as

Code: Select all

 
 
$q1 = "select * from m1";
$r1 = mysql_query($q1) or die(mysql_error());
$a1 = mysql_fetch_array($r1);
 
$q2 = "select * from m2";
$r2 = mysql_query($q2) or die(mysql_error());
$a2 = mysql_fetch_array($r2);
 
 



Hope you friends got what i mean ?? how i then for 2 or more tables i can write the exchange code btw tables upon lang just as example (1)

thanks in advance

Re: change btween tables...!

Posted: Sat Oct 03, 2009 4:48 pm
by egturnkey
any help :-

i mean how to write such as

Code: Select all

 
 
if($lang == "en")
   $table_name="en_m1";
 
 
else if($lang == "ar")
   $table_name="ar_m1";
 
 
$q1 = "select * from $table_name";
$r1 = mysql_query($q1) or die(mysql_error());
$a1 = mysql_fetch_array($r1);
 
 
if($lang == "en")
   $table_name2="en_m2";
 
 
else if($lang == "ar")
   $table_name2="ar_m2";
 
 
$q2 = "select * from $table_name2";
$r2 = mysql_query($q2) or die(mysql_error());
$a2 = mysql_fetch_array($r2);
 
 
 


indeed that is wrong and will gives error so any idea how i do such thing...


thanks in advance