<?php
require_once('includes/load.php');

if(isset($_GET['part_number'])) {
    $part_number = $db->escape($_GET['part_number']);
    
    $sql = "SELECT categorie_id FROM products WHERE part_number = '{$part_number}' LIMIT 1";
    $result = $db->query($sql);
    
    if($db->num_rows($result) > 0) {
        $data = $result->fetch_assoc();
        echo json_encode([
            'success' => true,
            'categorie_id' => $data['categorie_id']
        ]);
    } else {
        echo json_encode([
            'success' => false,
            'message' => 'Part number not found'
        ]);
    }
} else {
    echo json_encode([
        'success' => false,
        'message' => 'No part number provided'
    ]);
}
?>