return $result; } function get_type($product_id, $type_delete, $type_active) { $sql = "SELECT `type_`.`type_id`, `type_`.`type_name`, SUM(`stock_quantity`) AS `total_qty`, `type_delete` \n\t FROM `tbl_product_type` AS `type_` INNER JOIN `tbl_product_stock` AS `stock_` ON `type_`.`type_id` = `stock_`.`type_id`\n\t\t\t\t WHERE `product_id`= '{$product_id}' AND `type_delete` = '{$type_delete}' AND `type_active` = '{$type_active}'\n\t\t\t\t GROUP BY `type_`.`type_id`\n\t\t\t\t"; $query = $this->conn->query($sql); $row = array(); while ($result = $query->fetch_object()) { array_push($row, $result); } return $row; } } $_ajax = new AJAX(); $ajax_id = filter_var($_POST['product_id'], FILTER_SANITIZE_EMAIL); $count = $_ajax->count_type($ajax_id, 0); if ($count->rows > 0) { $data = $_ajax->get_type($ajax_id, 0, 1); echo '<label class="control-label col-xs-3">Type Name</label>'; echo '<div class="col-xs-9">'; echo '<select name="type" id="id-modal-type" class="form-control" tabindex="4">'; foreach ($data as $data) { echo '<option '; if ($data->total_qty == 0) { echo 'disabled="disabled"'; } else { if ($data->type_delete > 0) { echo 'class="hidden"'; } } echo ' value="' . $data->type_id . '">' . $data->type_name . '</option>';