Here I bring the data I need:

$senders = $this->db->query("SELECT * FROM `" . DB_PREFIX . "sum_back_newposhta` WHERE `id` < 100")->rows; $ei_numbers = array(); foreach ($senders as $sender) { $ei_numbers[] = array( 'DocumentNumber' => $sender['ttn'], 'Phone' => $sender['phone'], ); } 

Here pass

 $documents = $novaposhta->tracking($ei_numbers); 

Here I get what I need

 foreach ($documents as $document) { $set_arr[] = array( 'sum_back' => $document['RedeliverySum'], ); if ($set_arr) { $this->db->query("UPDATE `".DB_PREFIX."sum_back_newposhta` SET `sum_back`='" . $this->db->escape($document['RedeliverySum']) . " WHERE ttn = '" . $number_ttn ."'"); echo $document['RedeliverySum']." OK\n\r<br>"; } } 

But updates do not work from WHERE ttn = '" . $number_ttn . How do I need to make the updates be recorded in the desired id?

  • Use condition id = 123 instead of ttn = 'smth' ? - Dmitriy Simushev
  • I visited WHERE id = '". $ Senders [$ document [' Number ']] [' id '] but the request does not pass, I understand that I need to correctly compile this part of the request so that I can check what amount corresponds to the required Id can’t understand this id - Roman Yushko

1 answer 1

I assume that this is a syntax error:

 SET `sum_back`='" . $this->db->escape($document['RedeliverySum']) . " WHERE 

Opened the bracket ' but did not close after ".$this->db->escape($document['RedeliverySum'])."