Click to See Complete Forum and Search --> : PLiz help...


delr2691
03-23-2005, 10:47 AM
Hey,
I have a problem,
i want to submit data in a db like this:
i have input fields which are randomly named...
but the name of the fields are stored into an array...
for example fields = array('field1', 'field2', 'etc');
and i want to take the fields value to enter it (the value) into a database...

i tried this:
foreach ($fields as $field) {
$enterField = $_POST["$field"];
$insert = "Insert into bla bla bla";
mysql_query($insert);
}
but this didn't work...
because it is trying to get the value of the field named "$field" which does not exist...!
help me with this one pliz...
thanx

phpnovice
03-23-2005, 04:25 PM
I believe that this:

$enterField = $_POST["$field"];

should be this:

$enterField = $_POST[$field];

delr2691
03-23-2005, 04:59 PM
it worked...
thanx phpnovice

phpnovice
03-23-2005, 06:15 PM
Cheers.