I am not the best at writing complicated (for me) mysqli queries.
I am trying to create one array using data from two different tables.
TABLE 1: text_strings
id string
1 hello
2 good_morning
TABLE 2: text_translations
id textid lang translation
1 1 en Hello
2 1 es Hola
3 2 en Good Morning
4 2 es Buenos Dias
So, I am trying to make an array of translations based on the language. If my language is set to Spanish (es), the array would be like:
['hello'=>'Hola','good_morning'=>'Buenos Dias']
So, the structure of the array would be:
$lang['string'] = ['translation'];
In written English, if language is "es", select all from "text_translations" where lang is "es" and make the array key equal the value of the textid string value in the "text_strings" table.
I'm assuming something with LEFT JOIN
, but I really don't know how to set up this query.
Thats pretty simple JOIN. Fetch this query from db to array.