0

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

2 Answers 2

2

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
Sign up to request clarification or add additional context in comments.

Comments

2
$get = $_GET;

$get['page'] = 2;

echo '<a href="book.php?<?php echo http_build_query($get); ?>">Page 2</a>';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.