Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form question

Status
Not open for further replies.

axman505

Technical User
Jun 20, 2001
489
US
I have a form which prompts a user for a table name, and for a number of fields. This data is processes displaying a certain amount of fields in a new form based on the number entered by the user. The names of each field increment like:
name1
name2
name3

My problem is, i need to pass all these value to another form. How do i go about captures all this value into another form?

This is my incorrect thought process so far:

<?php
$num_fields=$_POST['fields']; // passes number of fields
print $num_fields;
$num=&quot;1&quot;;
for ($i=0; $num_fields > $i; $i++) {
$field$num=$_POST['field$num'];
$num++;
}
?>
 
Name the fields name[1], name[2] and so on and you would get an array to the next script. //Daniel
 
but hwat if name[1] hsa value, but name[2] doesnt, and name[3] does, can you have wholes between values?
 
You could use something like this:
Code:
foreach ($_POST['name'] as $num => $name)
{
    echo &quot;Name $num is $name.<br />&quot;;
}
//Daniel
 
here is what i got,

the form is generating names like &quot;name[$r]&quot; .. which will send all the values as an array named &quot;name&quot;

now, how to i captures this in the next form?? i tried this:

$test=array();
$test=$_POST['name'];

however that didnt seem to work .. any other suggetsions?
 
That should work. Did you try a print_r($test); after those two lines? //Daniel
 
ok, i swear that didnt work 2 seconds ago, but its all good now .. thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top