<?php
error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE & ~E_DEPRECATED);
ob_start();
session_start();
if($_SESSION['sml_si']!=session_id()) {
    die();
}
require_once("../../db/connection.php");
require_once("../functions.php");
$id_map = (int)$_POST['id_map'];
$array = array();
if(empty($id_map)) {
    $query = "SELECT id,image,id_map FROM sml_icons WHERE id_map IS NULL ORDER BY id DESC;";
} else {
    $query = "SELECT id,image,id_map FROM sml_icons WHERE id_map=$id_map OR id_map IS NULL ORDER BY id DESC;";
}
$result = $mysqli->query($query);
if($result) {
    if($result->num_rows>0) {
        while($row=$result->fetch_array(MYSQLI_ASSOC)) {
            if(empty($row['id_map'])) $row['id_map']='';
            $array[]=$row;
        }
    }
}
ob_end_clean();
echo json_encode($array);