<!DOCTYPE html>
<html>
<head>
  <title></title>
  <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css">
</head>
<body>
<?php
  require_once("models/config.php");
  if(isUserLoggedIn()) { 
    
  }else{
    header("Location: index.php"); die(); 
  }
  
$mysqli = new mysqli("localhost", "bdicentralserver_sc", "Myl-PGfSbzcf", "bdicentralserver_sc");
              $result_pro = $mysqli->query("SELECT DISTINCT id_subcategoria FROM pricefile_mx p INNER JOIN product_xref_user pxu ON pxu.product_id = p.id WHERE pxu.user_id = ".$loggedInUser->user_id);

?> 
        
            <?php 
            $i = 1;
            $categorias = array();
            while ($row = $result_pro->fetch_assoc()) {
              $result_pro1 = $mysqli->query("SELECT parent_id FROM categorias_mx WHERE id = ".$row["id_subcategoria"]);
              $row2 = $result_pro1->fetch_assoc();
              $result_pro2 = $mysqli->query("SELECT * FROM categorias_mx WHERE id = ".$row2["parent_id"]." ORDER BY nombre ASC");
              $row3 = $result_pro2->fetch_assoc();
              if (!in_array( $row3["id"], $categorias)) {
                $categorias[] = $row3["id"];
              }
            }
            echo "<pre>";
            print_r($categorias);
         ?>


</body>
</html>