Reputation: 1892
Basically my question is:
mysite.php?searchword=vinegar?page=2
In the above url is it possible to GET both the search value (which here is vinegar) and the page value (here 2) with PHP code?
It comes from searching a large mysql table for the word vinegar, and then paginating the results. If this is not how possible, please could you suggest a way to do this
Thanks
Upvotes: 1
Views: 3833
Reputation: 239571
The question mark in a URL denotes the beginning of the query string. Your URL may contain only one query string. Within the query string, multiple key=value pairs are separated by an ampersand, &:
mysite.php?searchword=vinegar&page=2
PHP makes the contents of your query string available via the super-global associative array $_GET
:
$_GET['searchword']; # "vinegar"
$_GET['page']; # "2"
Upvotes: 3
Reputation: 76910
You should use
mysite.php?searchword=vinegar&page=2
and in php
$search = $_GET['searchword'];
$page = $_GET['page'];
Upvotes: 2
Reputation: 98
mysite.php?searchword=vinegar&page=2
$word = $_GET["searchword"]
$page = $_GET["page"]
Thats all you need.
Upvotes: 1
Reputation: 8990
There should only be 1 question mark after the .php
.
The URL should be written like this: mysite.php?searchword=vinegar&page=2
, then PHP will get both the searchword and page value.
Upvotes: 1
Reputation: 7374
No because the syntax is wrong. URL parameters should be in the format:
mysite.php?searchword=vinegar&page=2
And then you use $_GET['chword']
and $_GET['page']
to retrieve them in PHP
Upvotes: 1