I have a form which can add additional fields by j/s.
I am trying to get the values to insert into a single row.
Normally you would use a foreach statement. I have tried that for each field and that works but I cannot find how to combine these. There are lots of ways to separate out the arrays but they still appear to need a foreach statement.
The form fields look like this
File Name:: <input type="text" class="" name="file_name[]" />
File:: <input type="text" name="files[]" value="" />
I have tried a double foreach as follows
if(isset($_POST['file_name'])){
$file_name = $_POST['file_name'] ;//echo $_POST['file_name'];
}
if(isset($_POST['files']))
{$files = $_POST['files'] ;
}
foreach($file_name as $file_n){
foreach($files as $file){
$wpdb->insert( 'table', array ('project_ref'=>
$reference,'project_name'=>$fil_n,'project_link'=>$file));
}}
Problem is that if you complete two rows of the fields it inserts 4 rows. Very frustrating