To solve this, create a page called index.php
, inside it, you will have language options, only flags of each country for example.
You will then have a choice, depending on the choice you will be redirected to the same page but with a different parameter, this code could be used in index.php
eg
<a href=pagina_inicial.php?lang=pt_PT >Português</a>
<a href=pagina_inicial.php?lang=en_US >Inglês</a>
And then inside your "file that connects to bd" from which you posted the code in your question, it would work like this:
$lang = $_GET['lang'];
if ($lang == "pt_PT")
$conn->exec("SET lc_time_names = 'pt_PT'");
else
$conn->exec("SET lc_time_names = 'en_US'");
You may be wondering " Why did not I just do it this way? :"
$lang = $_GET['lang'];
$conn->exec("SET lc_time_names = '".$lang."'");
Because it would become a highly vulnerable target for SQL Injection attacks , so it would be very insecure ( never use user-uploadable variables within SQL )
In this way I told you, you can know what language the user wants, at the moment of executing his command, via a parameter that he sent when choosing which language on page index.php
.