<?php
include('../db/connection.php');

$variant_id = $_GET['variant_id'];

$query = "SELECT V.id,V.variant,B.brand,M.model,V.price 
          FROM variant V
          LEFT JOIN model M ON M.model_id = V.model
          LEFT JOIN Brand B ON B.brand_id = V.brand
          WHERE V.id = '$variant_id' AND V.deletion = 0";

$res = mysqli_query($conn, $query);
$data = mysqli_fetch_assoc($res);

$image_query = "SELECT images FROM drone_images 
                WHERE variant_id='$variant_id' 
                AND type='image' 
                AND deletion=0 LIMIT 1";

$image_res = mysqli_query($conn, $image_query);
$image = mysqli_fetch_assoc($image_res);
?>

<div class="thisProductDiv" data-variant="<?php echo $variant_id; ?>">
    <div class="imageDiv d-flex align-items-center justify-content-center">
        <img src="../documents/new_drones/<?php echo $image['images']; ?>" 
             style="max-width:100%; max-height:100%; object-fit:contain;">
    </div>

    <div class="contentDiv">
        <div class="drone_name">
            <?php echo $data['brand']." ".$data['model']." ".$data['variant']; ?>
        </div>
        <div class="price_content">
            Rs. <?php echo number_format($data['price']); ?>
        </div>
        <div class="btnSection"><div class="contact_dealer">Contact Dealer</div></div>
    </div>
</div>
