Sending multiple values from a form having same field names.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

How can I send multiple values from a form to be stored in a database, as
name of the fields is the same?

For example:

<?php
foreach ($field_data as $field) {

         $field_name=$field["field_name"];
         $field_id=$field["field_id"];
         $datatype=$field["datatype_name"];

?>
<input type="hidden" name="field_id" value="<?php echo $field_id;?>" />
<tr>
<td><strong><?php echo $field_name;?><strong></td>
<?php
     if ($datatype=="text" || $datatype=="integer") {
            echo "<td><input type=\"text\" name=\"field_data\"></td>";
     }
     elseif ($datatype=="textarea") {
          echo "<td><textarea rows=\"10\" cols=\"100\"
name=\"field_data\"></textarea><br></td>";
      }
      echo "</tr>";
}
?>

This creates a form with field names and text box or textarea box next to
each field name depending on the datatype. After the user enters the
values in the text or textarea and clicks submit, the values should get
stored in a database. But what is happening is that only the value entered
in the last field of the form is getting entered into the database.
This code is embedded in an application which is having an inbuilt
structure of taking the values from a form in a hash. Since key is the
same (i.e. field_id) everytime, the value gets overwritten and only the
last value gets stored in db. But I am not able to work out a solution for
this.
I hope I am able to make my problem clear enough.

Thanks,
Suamya.



 
-----------------------------------------------------------------------------
DISCLAIMER:- 
          "The information in this e-mail is confidential, and is intended 
solely for the addressee or addressees. If you are not the intended recipient,
 please delete the mail and kindly notify the sender of misdelivery. Any 
unauthorised use or disclosure of the contents of the mail is not permitted 
and may be unlawful."
-----------------------------------------------------------------------------

                         "Scanned By MailScanner"


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux