Jump to content

$_GET Key


Baving

Recommended Posts

I am currently using this script: -

[code]<? if ($_GET) {

$mode = key($_GET);
print $mode;
}

?>[/code]

Which is grabbing the text on the $_GET. But this is only collecting the first bit of information e.g.:-

index.php?permission

It would only print permission.

Is there anyway so that it will get more information from the $_GET statment? e.g.

index.php?permission&group=A

So it would print

permission&group=A

Thanks.
Link to comment
Share on other sites

well there are many ways to access parts of a query string like that. try these out and see what you get:
[code]
<?php
// entire query string
echo $_SERVER['QUERY_STRING'];

// individual items:
foreach ($_GET as $key => $val) {
  echo "{$key} => {$val}<br />\n";
}
?>
[/code]

good luck
Link to comment
Share on other sites

[quote author=obsidian link=topic=110257.msg445375#msg445375 date=1159807699]

[code]
<?php

// individual items:
foreach ($_GET as $key => $val) {
  echo "{$key} => {$val}<br />\n";
}
?>
[/code]

good luck
[/quote]

That is what I am needing :)

Any ideas how I could return the array to insert it into a database?

So..

$query = mysql_query("INSERT INTO whatever (list) VALUES('$input')");

With $input being the contents of the foreach array?

Link to comment
Share on other sites

or, just do it all at once in your query if that's what you're after:
[code]
<?php
$q = mysql_query("INSERT INTO table (" . implode(',', array_keys($_GET)) . ") VALUES ('" . implode("','", $_GET) . "')");
?>
[/code]

don't forget to implode() with the quotes around all your values
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.