I am quite new in this and I don't know what I am missing or not doing right here it is my php file.
file.php
session_start();
      if (!isset($_SESSION['userlevel'])){ 
         header('Location: /php/logout.php');
      }else{
        $tu =  $_SESSION['user_level'];
        $userid = $_SESSION['id'];
        $username = $_SESSION['user'];
      }
$conn = new mysqli("localhost", "root", "1234", "database");
if ($tu == 3){
$array = [];
$result = mysqli_query("SELECT COUNT(*) as nformadores FROM formador;");
if(mysqli_num_rows($result) <= 0){
    echo "Error";
}else{
    while($obj = mysqli_fetch_row($result)){
    $array['nformadores'][] = $obj;        
}
}
$result = mysqli_query("SELECT COUNT(*) as nareas FROM area;");
if(mysqli_num_rows($result) <= 0){
    echo "Error";
}else{
    while($obj = mysqli_fetch_row($result)){
    $array['nareas'][] = $obj;        
}
}
echo json_encode($array);
In my php file where I have my html code I am calling this:
$(document).ready(function(){
  $.ajax({
       url: "file.php",
       dataType:'json',
     success: function(data){
       var uno=data[0];
       var due=data[1];
           $("#query1").html(uno);
           $("#query2").html(due);
    }
  });
});
I want to write the result of the first query in the HTML element with the id="query1" and the result of the second query in the HTML element with the id="query2". And I want to do it in only one ajax call. What am I missing?
Thank you so much for your help.
 
     
    