change btween tables...!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
egturnkey
Forum Commoner
Posts: 34
Joined: Sun Jul 26, 2009 7:35 pm

change btween tables...!

Post 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
egturnkey
Forum Commoner
Posts: 34
Joined: Sun Jul 26, 2009 7:35 pm

Re: change btween tables...!

Post 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
Post Reply