I have a form having 2 fields .
<td class="left"><input style=" width: 30%; text-align: center;" type="text" name="name[]" value="<?php echo $geo_zone['name']; ?>" /></td>
<td class="left"><input style=" width: 30%; text-align: center;" type="email" name="email[]" value="<?php echo $geo_zone['email']; ?>" /></td>
if i print_r my arrays i get perfect result. like this
$name = $this->request->post['name'];;
$email = $this->request->post['email'];;
but what i want is to keep inserting these two values in database until arrays are empty ($name and $email).For this i tried for each loop but it only inserts one row in database.
foreach( $name as $key => $n ) {
$this->data['geo_zone_id']=$this->model_module_shipping_pools->Get_geo_zone_id($n);
$geo_zone_id=$this->data['geo_zone_id'];
$geo_zone_id=$geo_zone_id[0]['geo_zone_id'];
$this->model_module_shipping_pools->drop_data();
$email=$email[$key];
$this->model_module_shipping_pools->insertData($geo_zone_id,$email);
}
$email=$email[$key];
- you're overwriting your $email
variable. Call it something else.