<?php

    header("Content-Type: application/json");

    require '../config/conn.php';

    $fetchAvatars = "SELECT * FROM `avatars` WHERE 1";

    $fetch=mysqli_query($conn,$fetchAvatars);

    if($fetch)
    {
        if(mysqli_num_rows($fetch)>0)
        {
            $response['statusCode']=0;
            $response['message']='Avatars fetched successfullly';
            while($row=$fetch->fetch_assoc())
            {
                $response['avatarsList'][]=$row;
            }
        }
        else
        {
            $response['statusCode']=1;
            $response['message']="No avatars avalaible";
        }
        
    }
    else
    {
        $response['statusCode']=4;
        $response['message']="Error in fetching avatars";
    }

    echo json_encode($response);



?>