This is similar to a question that hexalix helped me with recently. Trying to update a table from a multiple field form I tried using similar code from that question but to no avail. Form field as follows:
<input type="hidden" name="file_id[]" value="<?php echo $file_id; ?>"/><input type="text" class="" name="files[]" id="files" value="<?php echo $file_name; ?>" /></p>
The form is then passed on to the following
if(isset($_POST['BIM-link'])){ $bim_link = ($_POST['BIM_link'] ); } if(isset($_POST['BIM'])){ $bim = ($_POST['BIM'] );//echo $bim; } $bim_id = $_POST['bim_id'] ;//echo $bim_id; } $total = count($_POST['bim_name']); for($i = 0; $i < $total; $i++) { $bim = $_POST['BIM'] [$i]; $bim_link = $_POST['BIM_link'] [$i]; $bim_id=$_POST['bim_id'] [$i]; $wpdb->update( 'vo_wp_autodesk', array ('autodesk'=>$bim,'autodesk_link'=>$bim_link),array( 'id' => $bim_id));}
this works fine for an insert so what am I missing here. As part of the testing I stripped out the for statement and hardcoded the values - so the update query does work
$wpdb->update
has a return value showing how many rows it updated orfalse
if it failed, what value does it have? And have you tried printing out the values of$bim_link
and$bim_id
to check directly if they are what you're expecting them to be? Your first snippet has names such asfile_id
andfiles
but your second refers to BIM`BIM_link
andbim_id
which aren't mentioned elsewhere