CodeIgniter Forums

Full Version: Multiple input arrays[]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum


I'm struggling to get my head around doing the following:

I get that the inputs will have to have array[] names, but how do I go about processing this in PHP. To look through each row?

Each row will be added into the database as an award.

Any help/guidance will be greatly appreciated Smile

El Forum

here is the solution first get all variables from post

$array = $this->input->get_post('array');
$array2 = $this->input->get_post('array2');
now loop for data
foreach($array as $key => $val){
  if($val != '')
  $data['db_fieldname'] = $v;
  if($array2[$key] != '')
  $data['db_fieldname2'] = $array2[$key];
  if($_FILES[$key][error] != 4)
   do uploading

hope this will help you to solve you problem.

El Forum

The HTML is :

You'll see with each row I need to insert this into the DB, so I'll just put that in a loop, however, it's how do I get all 4 things to just be only 1 row. Doing the foreach on the $_POST is getting everything I post, I want to be able to group-so-to-speak the inputs by row.

Thanks for the continuing support Smile