Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

Arrays

Links for php scripts

Moderators: macek, egami, gesf

Arrays

Postby sinichi » Tue Oct 23, 2012 7:30 pm

Hi guys good day,

i have a url http://www.myanis.com/edit.php?id[]=1&name[]=steve&id[]=2&name[]=aldrin

now to get this, i have to use?? foreach right? something like this??

foreach($_GET['id'] as $id){
//codes
}
and
foreach($_GET['name'] as $name){
//codes
}

and ive tried like this, to shorten the codes.

foreach($_GET['id'] as $id && $_GET['name'] as $name){
//codes
}

is this wrong???? or is there a way to to do like that the correct way.

my purpose is that to insert data in my database

foreach($_GET['id'] as $id && $_GET['name'] as $name){
//sql insert statement.
}
sinichi
New php-forum User
New php-forum User
 
Posts: 1
Joined: Tue Oct 23, 2012 7:19 pm

Re: Arrays

Postby egami » Wed Oct 24, 2012 10:47 am

I don't think that's going to work. While I do not officially know for sure if you can iterate through 2 arrays at once, but I really don't think so.

Not something that I would try anyway, just doesn't seem logical..
yOu'll have to do them one by one.
User avatar
egami
php-forum GURU
php-forum GURU
 
Posts: 2197
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT


Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 0 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.