F
F
freeman02042016-11-25 13:54:10
PHP
freeman0204, 2016-11-25 13:54:10

When changing the language, get parameters are lost, how to fix it?

Switch structure via get

<div class="lang">Язык:<a href="?lang=en">English</a>|<a href="?lang=ru">Русский</div>

in the database there are 2 tables with endings in the names _ru and _en the switching goes in this way, in short,
$result = mysql_query("SELECT * FROM stores_".$_SESSION['lang']);
block is substituted. $_SESSION['lang'].
If to speak about pages of type about.php?lang=enthat switching goes normally.
And if we talk about such links /shop.php?type=stores&id=25&lang=en, then when you click on the language switch, there is a link shop.php?lang=en без type=stores&id=25that is not correct and leads to an error on the page.
I used this echo substr($_SERVER['REQUEST_URI'], 0, -8);to find out the url and cut off the excess, since I wrote lang=en or lang=ru 2 times in the url, but this leads to problems on pages like about.php?lang=en (cuts off the excess).
In general, I think this is a crutch. How to make it so that the switching was normal? I think you understand what I mean. Provided that the language change will be through get parameters i.e. like me now.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
wangler, 2016-11-25
@freeman0204

Try parsing (parse_url) the query values ​​and reassembling them in the link.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question