-1
  $no = mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT 5");
  while($n = mysql_fetch_array($no)){
     $message = $n['message_RS'];

     if(strlen($message) > 50){ 
          $message = substr($message,0,50); 
          $message .= "..."; 
     }   

      echo " <div class='text'> <p> <a href='#'>$n[title]</a> <br /> <small>$message</small> </p> </div> ";
  }

In line :

$message = $n['message_ HERE GOING LANGUAGE'];
Language = $_COOKIE['language'];

I just need from table to fetch a row for seleted language any help

4

2 回答 2

0
$message = $n['message_' . $_COOKIE['language']];
于 2015-04-14T12:24:56.393 回答
0
  $no = mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT 5");
  while($n = mysql_fetch_array($no)){

     // lang
     $lang = $_COOKIE['language'];
     if($lang == "en"){
         $lang = "EN";
     } else if($lang == "srb"){
         $lang = "RS";
     } else if($lang == "ru"){
         $lang = "RU";
     }

     $message = $n['message_'.$lang];

     if(strlen($message) > 50){ 
          $message = substr($message,0,50); 
          $message .= "..."; 
     }   


      echo " <div class='text'> <p> <a href='#'>$n[title]</a> <br /> <small>$message</small> </p> </div> ";
  }
于 2015-04-14T13:48:12.383 回答