$_POST[] question

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

Post Reply
nincha
Forum Contributor
Posts: 191
Joined: Fri Mar 28, 2003 12:30 pm
Location: CA, USA

$_POST[] question

Post by nincha »

say i use a loop to create 20 input in a form. Each input's name is item1, item2, item3.... etc. Now i send it to a php script, how would i use a loop to read the inputs value?
nincha
Forum Contributor
Posts: 191
Joined: Fri Mar 28, 2003 12:30 pm
Location: CA, USA

Post by nincha »

nevermind about the question, i just found out a way to do this, thnx anyways guys.
valen53
Forum Contributor
Posts: 137
Joined: Tue Aug 27, 2002 9:29 am

$_post

Post by valen53 »

" how would i use a loop to read the inputs value? "

can u tell me how u to do that ? cause i also facing this problem now..
thank's reply
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

I'd imagine just call for the results in a similar way you would loop the text input areas. :)
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Re: $_post

Post by twigletmac »

valen53 wrote:" how would i use a loop to read the inputs value? "
Check out variable variables:
http://www.php.net/manual/en/language.v ... riable.php

Mac
nincha
Forum Contributor
Posts: 191
Joined: Fri Mar 28, 2003 12:30 pm
Location: CA, USA

Post by nincha »

i dont know if this is the "real" way to do it but say the the inputs name were item1, item2, item3.. etc. I use this loop to do it

Code: Select all

//$item_num is a variable i set in the loop to create the inputs so i have a count of inputs the loop does.
//I use the substr_replace to add $count to the end of $name getting item1 than item2 etc.


                for($count=1;$count<=$item_num;$count++)
	&#123;
	$name="item";
	$name=substr_replace($count,$name , 0, 0);
	$store_item&#1111;$count]=$_POST&#1111;$name];
                &#125;
Post Reply