Data entered by user:
"product_description": [{
"language_id": 1,
"name": "okayt321sd1a"
}
Update database:
foreach ($data['product_description'] as $product_description) {
foreach ($product_description as $key => $value) {
$a[$key] = $value;
if($a[$key]){
$this->db->query("UPDATE " . DB_PREFIX . "product_description SET language_id = '" . (int)$language_id . "', name = '" . $this->db->escape(html_entity_decode($product_description['name'])) . "', meta_keyword = '" . $this->db->escape(html_entity_decode($product_description['meta_keyword'])) . "', meta_description = '" . $this->db->escape(html_entity_decode($product_description['meta_description'])) . "', description = '" . $this->db->escape($product_description['description']) . "', tag = '" . $this->db->escape($product_description['tag']) . "',
page_title = '" . $this->db->escape($product_description['page_title']) . "',
highlight = '" . $this->db->escape($product_description['highlight']) . "',
whatbox = '" . $this->db->escape($product_description['whatbox']) . "' WHERE product_id = '" . (int)$product_id . "',
");
}
}
}
How can I update data based on user enter, for example, if user enter
"language_id": 1,
"name": "okayt321sd1a"
then I only update this 2 data to database other data will remain, if enter 3 data:
"language_id": 1,
"name": "okayt321sd1a"
page_title
then I only update this 3 data to database other data will remain.