I deduce the type of goods that the user has posted from the table table_products. In the table table_products there is a name column (there are all categories in English) How can I make it so that I pull out from the database in English, and the site shows in Russian?
By the way, I have a table of another category where there are these categories in Russian name_ru

$result1 = mysql_query("SELECT * FROM table_products WHERE products_id='$id'",$connect); 


I deduce

 <p id="nav-info"><a href="view_things.php">Вещи</a>/<span>'.$row1["name"].'</span></p> 


that's how it shows on the site
enter image description here

  • but what prevents to bring $ row1 ['name_ru'] - Naumov
  • Does not work. name_ru in another table (category), and this is table_products product offered by the user - Eugene

2 answers 2

You can create additional columns in the database:

  • name_ru
  • name_en

And to make a condition - if the session / language cookie - ru, will be taken from $row1['name_ru'] .

And if you need to take the name_ru/eng from another table, then you can use INNER JOIN:

  SELECT * FROM table_products as p INNER JOIN category as c ON p.category_id = c.id WHERE p.id=$id 

And after the selection, you can also give the required fields depending on the site language.

  • SELECT * FROM table_products as p INNER JOIN category as c ON p.category_id = c.id WHERE p.id = $ id does not display anything at all :( - Eugene
  • @ Eugene, Do you have a category_id column in table_products? And you can look at the table? - sasha_t
  • No, no. How to show you? - Eugene
  • Then it is clear why the code does not work. My code implies that you will have a category_id in table_products - which will lead to the category table id. And in category there should already be columns with different languages. Therefore, if you have category_id = 1 in your products, this means that you must have a category entry with id = 1. - sasha_t
  • I have a category with parent and child lists of Russian and English, but when the user offers a product, then the value in table_products goes to the database - Eugene

You can create an association table (locale) with the columns en_category_id and ru_category_id . The number of columns depends on the number of localization languages.