you can leave the below code they way it is it’d fine.
[php]
mysql_query(“UPDATE $lang_ro SET val = ‘$nav_home’ WHERE var = ‘nav_home’”);
mysql_query(“UPDATE $lang_ro SET val = ‘$nav_project’ WHERE var = ‘nav_project’”);
mysql_query(“UPDATE $lang_ro SET val = ‘$nav_forum’ WHERE var = ‘nav_forum’”);
mysql_query(“UPDATE $lang_ro SET val = ‘$nav_db’ WHERE var = ‘nav_db’”);
mysql_query(“UPDATE $lang_ro SET val = ‘$nav_contact’ WHERE var = ‘nav_contact’”);
mysql_query(“UPDATE $lang_ro SET val = ‘$nav_faq’ WHERE var = ‘nav_faq’”);
[/php]
however to avoid retrieving the data from database multiple times you can set a condition so the data will retrieved once.
for example when the data is retrieved you can set a cookie or a session and only retreive if the session is not yet set.
the below code
[php]
if ((isset($_SESSION[‘lang’])) && (!isset($_SESSION[‘retrieved’])))
{
if ($_SESSION[‘lang’] == ‘ro’) {
$sql = mysql_query("SELECT var, val FROM $lang_ro");
$lang = array();
while ( $row = mysql_fetch_assoc($sql)) {
$lang[$row['var']] = $row['val'];
}
$_SESSION['retrieved'] = "already retrieved once":
}else if ($_SESSION['lang'] == 'hu') {
$sql = mysql_query("SELECT var, val FROM $lang_hu");
$lang = array();
while ( $row = mysql_fetch_assoc($sql)) {
$lang[$row['var']] = $row['val'];
}
$_SESSION['retrieved'] = "already retrieved once":
}
}else{
$sql = mysql_query("SELECT var, val FROM $lang_ro");
$lang = array();
while ( $row = mysql_fetch_assoc($sql)) {
$lang[$row['var']] = $row['val'];
}
}
[/php]
finally once you update the records from admin user you can happlu unset that session so that if he he wants to edit something else the scriipt will load all is info again
[php]
unset($_SESSION[‘retrieved’]);
[/php]
don’t forget to use session_start();
cheers