PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
ianhull
Forum Contributor
Posts: 310 Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK
Post
by ianhull » Sun Feb 18, 2007 4:15 pm
Hi Guys,
can anyone please tell me why this is happening?
It is only returning the last values.
Code: Select all
<?php
foreach ( $_GET as $varName => $postData )
$columnName = array("{$varName}",);
$dataValue = array("{$postData}",);
print_r(array_combine($columnName,$dataValue));
?>
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Feb 18, 2007 4:44 pm
several things
$columnName is the only line in the loop.
your code is creating a new array each time $columnName is set, wiping out all previous information.
I don't see the point of this code. It appears you're simply copying $_GET.
ianhull
Forum Contributor
Posts: 310 Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK
Post
by ianhull » Sun Feb 18, 2007 4:49 pm
Thanks Feyd,
In the end I will be collecting data from a POST form and entering the data into my DB,
First of all what I'm tring to do here is retrieve all the posted data as value pairs and place them into an array for later insertion into my db.
I know that this is not very secure, but for now it is ok.
How would I get it to loop through all the posted data and place all entries into an array?
thanks
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Feb 18, 2007 5:04 pm