0

Currently I am getting the values from a form individually and then posting them to the db on submission. The code I have below works fine

$output['success'] = $wpdb->insert('my_Tablename', array(
    'one' => $one, 
    'two' => $two, 
    'three' => $three, 
    'four' => $four, 
    'five' => $five
));

but what if I want to post some fields to a supplemental table at the same time? How would I do that? Its not $output2 as I tried that, and I cant add a comma between the $wpbd inserts, so what would the solution be? I want to add:

$output['success'] = $wpdb->insert('my_Tablename_two', array( 
    'one' => $one, 
    'two' => $two, 
    'three' => $three, 
    'four' => $four, 
    'five' => $five
));
Phil
  • 157,677
  • 23
  • 242
  • 245
Manny
  • 81
  • 8
  • You could try recording the insert counts in separate variables, eg `$res1 = $wpdb->insert(...); $res2 = $wpdb->insert(...)` and then set the output to the combined total, ie `$output["success"] = $res1 + $res2;`. Of course, you probably want to perform these two inserts in a [transaction](https://stackoverflow.com/questions/19153986/how-to-use-mysql-transaction-in-wordpress) – Phil May 17 '21 at 01:33
  • brilliant that makes good sense, thank you – Manny May 17 '21 at 01:48

0 Answers0