} return $row; } function count_alias($size_type_id) { $sql = "SELECT COUNT(*) AS rows FROM tbl_size WHERE size_type_id = '{$size_type_id}' ORDER BY size_order"; $query = $this->conn->query($sql); $result = $query->fetch_object(); return $result; } } $_ajax = new AJAX(); $size_type_id = filter_var($_POST["size_type_id"], FILTER_SANITIZE_STRING); $type_order = filter_var($_POST["type_order"], FILTER_SANITIZE_NUMBER_INT); $count = $_ajax->count_alias($size_type_id); $check_array = $_ajax->get_alias($size_type_id); if ($count->rows > 0) { foreach ($check_array as $key => $check_array) { ?> <div class="form-group row" id="lbl_size_qty"> <label class="col-xs-3 control-label" for="Stock"> <?php if ($key == 0) { ?> Sizes<?php } ?> </label> <div class="col-xs-9">