Answer the question
In order to leave comments, you need to log in
Link with a GET request?
Suppose the current page address is: http://site.ru/page.php?one=p1
.
There is a link on the page, like: <a href="?two=p2">Тык</a>
.
But if you follow it, the one parameter will be erased and the current url will become: http://site.ru/page.php?two=p2
.
Question: How to specify a link so that it eventually redirects:
http://site.ru/page.php?one=p1
ON http://site.ru/page.php?one=p1&two=p2
.http://site.ru/page.php
ONhttp://site.ru/page.php?two=p2
Answer the question
In order to leave comments, you need to log in
It is necessary to check the presence of a GET parameter in the current URL and, based on this, generate link parameters
$urlParams = '';
if (empty($_GET)) {
$urlParams = '?two=p2';
} else {
$urlParams = '&two=p2';
}
<a href="$urlParams">Тык</a>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question