FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Php $_POST





piraba8
HI All;
I am new to php.I want to know how to get the $_post values.That is createded dynamically.
Here is the print_r($_POST);
====
Array ( [height] => 1.2 [length] => 46546 [gate] => Single Leaf [gatesize] => 4565 [gatesize_5] => 5654 [gatesize_7] => 5654 [gatesize_9] => 65465 [Submit] => NEXT )

here gatesize_5 ,gatesize_7,gatesize_9 --these values dynamically created that form.we dont know how many "gate_i" values.How can i get this values
i want to get like this


$gate= $_POST['gate'];
$gatesize = $_POST['gatesize'];
$gatesize_5 = $_POST['gatesize_5'];

Please any body help me.....
Regards
S.Piraba
rvec
use gatesize[] instead of gatesize_x and you'll get an array in $_POST['gatesize'] where you can loop through with foreach
jmraker
In HTML: In the form append [] (or [num] if they're not sequential) to the name like
Code:
<input name="gatesize[]" />
<input name="gatesize[]" />
....
<input name="gatesize[]" />
or
Code:
<input name="gatesize[0]" />
<input name="gatesize[14]" />
....
<input name="gatesize[999]" />


In PHP: $_POST['gatesize'] will be an array
Code:
foreach($_POST['gatesize'] as $k=>$v){
   ...
}


If for some reason you don't want to do that you can use isset() (to confuse others of your sanity)
Code:
$num = 1;
while(isset($_POST['gatesize_' . $num])){
   $gatesize = $_POST['gatesize_' . $num];
   ....
   $num++;
}
piraba8
Hi All;

Thank you very mush.I got it .its work fine
i did like this

in html
<input type='text' name=gatesize["+record_id+"] id=gatesize["+record_id+"] />"

then php:

$gatesizearray =array();
$gatesizearray=$_POST['gatesize'];

for($i=0;$i<count($gatesizearray);$i++){
$str.='&gatesizearray[]='.$gatesizearray[$j];
$j=$j+2;

}

then i passed this array values to anchor tag.

header("location: userIndex.php?page=feciMeshResult&height=$height&length=$length&mesh=$noofmesh&post=$post&gate=$gate&gatesize=$gatesize&totalbolt=$totalbolt".$str);


Thanks you all of your guide.

Regards;
S.Piraba
Related topics
PB PHP, Iframe and Javascript
Build an online dictionary by PHP/MySQL
PHP: Feedback form issues.. help =P
PHP Validation Class
How To : Improve Your PHP Programming
How To : Secure Your PHP Website
calcilation machine for php
[PhP] News Posting Tutorial (code, actually ^^')
PHP question, $_SESSION[] gets changes to by $_POST var
make a backoffice
array check box on php script using $_POST
php upload problems
PHP load array from $_POST
escapeshellcmd seems to blank my user input
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.