$def_type_page_title = $ct_default_type['page_title']; $def_type_page_description = $ct_default_type['page_description']; // PRODUCT TYPE insert_product_type_lang($lang_type_id, $def_product_id, $def_type_code, $lang_type_name, $def_type_price, $def_type_color_id, $lang_description, $def_type_weight, $def_type_new_arrival, $def_type_image, $def_type_order, $def_type_sold_out, $def_type_visibility, $def_type_delete, $def_type_alias, $def_type_page_title, $def_type_page_description, $lang_code); } } // END CHECK DML //} # ---------------------------------------------------------------------- # HOW TO & TECHNICAL DATA # ---------------------------------------------------------------------- // DEFINED VARIABLE if (isset($_POST['custom_lang_default_how'])) { $val_how = 'default'; } else { $val_how = $_POST['how']; } if (isset($_POST['custom_lang_default_technical'])) { $val_tech = 'default'; } else { $val_tech = $_POST['technical']; } // CHECK DML if ($check_how['rows'] > 0) { update_how($val_how, $val_tech, $def_product_id); } else { insert_how($def_product_id, $val_how, $val_tech, $lang_code); } $_SESSION['alert'] = 'success'; $_SESSION['msg'] = 'Changes successfully saved.'; }
<?php function insert_how($post_product_id, $post_how, $post_technical) { $conn = connDB(); $sql = "INSERT INTO tbl_product_custom (`product_id`, `how`, `technical`)\n VALUES('{$post_product_id}', '{$post_how}', '{$post_technical}')\n\t\t\t"; $query = mysql_query($sql, $conn) or die(mysql_error()); } function get_product_id_how() { $conn = connDB(); $sql = "SELECT MAX(id) as product_id FROM tbl_product"; $query = mysql_query($sql, $conn) or die(mysql_error()); $result = mysql_fetch_array($query); return $result; } if (isset($_POST['add-product'])) { // CALL FUNCTION $how_product_id = get_product_id_how(); // DEFINED VARIABLE $how = $_POST['how']; $technical = $_POST['technical']; insert_how($how_product_id['product_id'], $how, $technical); }