0

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

4
  • what is your table schema? $wpdb->update has a return value showing how many rows it updated or false 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 as file_id and files but your second refers to BIM` BIM_link and bim_id which aren't mentioned elsewhere
    – Tom J Nowell
    CommentedFeb 28 at 15:50
  • Hi folks After extensive testing, I noticed that there was a typo. if(isset($_POST['BIM-link'])){ should read if(isset($_POST['BIM_link'])){ Its always something simple.
    – Ian Young
    CommentedFeb 28 at 16:31
  • @Chris Cox I tried that but it wouldnt let me submit it as an answer
    – Ian Young
    CommentedMar 4 at 4:08

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.