Reputation: 3520
I have a question, How I can add another get variable in my current url
book.php?action=addressbook
i want to add
book.php?action=addressbook&page=2
how to generate hyperlink for this, i have tried it using $_SERVER['PHP_SELF'] but query string are not included in url its showing something like that
book.php?page=2
I want to append my other variables to query string
Please help
Upvotes: 0
Views: 2208
Reputation: 490213
$get = $_GET;
$get['page'] = 2;
echo '<a href="book.php?<?php echo http_build_query($get); ?>">Page 2</a>';
Upvotes: 2
Reputation: 17169
You can also use http_build_query(); to append more params to your URL
$params = $_GET;
$params["item"] = 45;
$new_query_string = http_build_query($params);
for instance:
$data = array('page'=> 34,
'item' => 45);
echo http_build_query($data); //page=34&item=45
or include amp
echo http_build_query($data, '', '&'); //page=34&&item=45
Upvotes: 2