mysql - Select from table where table = id if session is lang_code -


i'm trying select english menu title if session , current sql table "see code"

if($_session['lang_code'] == 'en') {     echo $coursecat['course_cat_title']; } else      echo $coursecat['course_cat_title'];  

it prints far dutch menu title, when in db have table shows language country id course_cat_lang_country, need know how can print english title when page www.yourdomain.nl/en/. full code use this.

$qcoursecat = mysql_query("select * web_course_cat course_cat_id = 1"); $coursecat = mysql_fetch_assoc($qcoursecat); echo "< h4>";  if($_session['lang_code'] == 'en') {      echo $coursecat['course_cat_title'];   } else      echo $coursecat['course_cat_title'];   echo "< h4>"; 

how this:

if($_session['lang_code'] == 'en') {     $table='course_cat_eng';  } else {     $table='course_cat_title'; }  $sql = "select * $table course_cat_id = 1"; if (! $resource = mysql_query($sql) ){     echo "error reading table $table"; } else {     if (!mysql_num_rows($resource ) ){         echo "no records foin in $table";     }     else {         $coursecat = mysql_fetch_assoc($resource);         echo "<h4>";         echo $coursecat['course_cat_title'];          echo "</h4>";         //...         // other stuff might want     } } 

please comment if not looking for, , revise answer.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -