Hi there.
I have got the hang of using the query string function but am interested in how to use multiple querry strings (such as http://www.site.com/index.php?id=32&page=73 ).
Also i am wanting to know how to use querry stings like this
http://www.marcusnoble.co.uk/index.php?page=Props
as at the moment i can ony get them like
http://www.marcusnoble.co.uk/index.php?Props
Thanks
Eric
PHP query stings
Moderator: General Moderators
- ericburnard
- Forum Contributor
- Posts: 104
- Joined: Wed Jun 15, 2005 5:11 pm
- Location: Chesterfield, UK
you just separate the URL vars with & then call them individually on your "action" page:
ex:
ex:
Code: Select all
<a href="e;actionpage.php?id=45&page=bob"e;>here</a>Code: Select all
echo $_GETї'id']."e;<br>"e;.$_GETї'page'];- ericburnard
- Forum Contributor
- Posts: 104
- Joined: Wed Jun 15, 2005 5:11 pm
- Location: Chesterfield, UK
ok i get whats there so far but where do i put the content i want displayed for that link?Burrito wrote:you just separate the URL vars with & then call them individually on your "action" page:
ex:Code: Select all
<a href="e;actionpage.php?id=45&page=bob"e;>here</a>Code: Select all
echo $_GETї'id']."e;<br>"e;.$_GETї'page'];
Eric
that really depends on how your page/site is set up.
if you're grabbing info from a db, you could populate your link with that information, or you could use already existing url vars, or local page vars, etc.
ex:
if you're grabbing info from a db, you could populate your link with that information, or you could use already existing url vars, or local page vars, etc.
ex:
Code: Select all
$row = mysql_fetch_assoc($result);
$somevar = $rowї'somefieldonyourtable'];
echo "e;<a href=\"e;actionpage.php?id="e;.$_GETї'id']."e;&page="e;.$somevar."e;\"e;>here</a>"e;;- ericburnard
- Forum Contributor
- Posts: 104
- Joined: Wed Jun 15, 2005 5:11 pm
- Location: Chesterfield, UK
My friend says that he uses the code
to get links like
http://eric.madashatters.com/archives.php?date=may
i have played arround with it to try and get it to work although it wont
HELP PLEASE!!
Eric
Code: Select all
$date = $_SERVERї"e;QUERY_STRING"e;]http://eric.madashatters.com/archives.php?date=may
i have played arround with it to try and get it to work although it wont
HELP PLEASE!!
Eric
and so what happens when you echo $date or just echo $_SERVER['QUERY_STRING']?
you should get something like: date=may right? All that does is display any url parameters along with their values.
so say for example you had:
http://www.mydomain.com/page.php?var1=b ... var3=larry
if you echoed the $_SERVER['QUERY_STRING'] of that you'd get:
var1=bob&var2=joe&var3=larry
now if you want to just grab the values of any of those parameters, you need to use the $_GET array and list the name of the parameter as the key of the value you want to retrieve.
ex:
the only time I ever use $_SERVER['QUERY_STRING'] is if I'm redirecting to another page but I want to remember where the user was when they were redirected (including the url params). I can then dump that value into a sesson var or a cookie or the db etc and recall it to send them back after I'm done doing whatever I want to with them.
hopefully that clears things up, if not let me know and I'll elaborate more.
you should get something like: date=may right? All that does is display any url parameters along with their values.
so say for example you had:
http://www.mydomain.com/page.php?var1=b ... var3=larry
if you echoed the $_SERVER['QUERY_STRING'] of that you'd get:
var1=bob&var2=joe&var3=larry
now if you want to just grab the values of any of those parameters, you need to use the $_GET array and list the name of the parameter as the key of the value you want to retrieve.
ex:
Code: Select all
echo $_GET['var1'];
// yields bobhopefully that clears things up, if not let me know and I'll elaborate more.