<?php require_once "connection.php"; ?>
<?php


// $outdoor_items;

$type = isset($_POST['type']) ? $_POST['type'] : null;
$id = isset($_POST['id']) ? $_POST['id'] : null;


if($type == 'outdoor') {
    $sql = "SELECT * FROM outdoor_item";
    $items = $conn->query($sql);
    
    while($item = $items->fetch_assoc()) { ?>
        <li class="outdoor_item <?php echo $item['id'] ?>"><?php echo $item['item_name']?></li>
    <?php    
    }
}

if($type == 'helicopter') {
    $sql = "SELECT * FROM helicopter_item";
    $items = $conn->query($sql);
    
    while($item = $items->fetch_assoc()) { ?>
        <li class="helicopter_item <?php echo $item['id'] ?>"><?php echo $item['item_name']?></li>
    <?php    
    }
}

if($type == 'racing') {
    $sql = "SELECT * FROM racing_item";
    $items = $conn->query($sql);
    
    while($item = $items->fetch_assoc()) { ?>
        <li class="racing_item <?php echo $item['id'] ?>"><?php echo $item['item_name']?></li>
    <?php    
    }
}

if($type == 'outdoor_item') {
    $sql = "SELECT * FROM outdoor_item WHERE id=" . $id;
    $items = $conn->query($sql);
    while($item = $items->fetch_assoc()) { ?>
        <div class="panel-body p-xl-4 p-md-4 p-2 bg-white br-rounded">
            <div class="p-2 row" id="item_details">
                <div class="col-md-4">
                    <img class="w-100" src="<?php echo $item['item_image']; ?>">
                </div>
                <div class="col-md-8 item-desc">
                    <p><?php echo $item['item_desc']; ?></p>
                </div>
            </div>
        </div>  
    <?php    
    }
}



if($type == 'racing_item') {
    $sql = "SELECT * FROM racing_item WHERE id=" . $id;
    $items = $conn->query($sql);
    while($item = $items->fetch_assoc()) { ?>
        <div class="panel-body p-xl-4 p-md-4 p-2 bg-white br-rounded">
            <div class="p-2 row" id="item_details">
                <div class="col-md-4">
                    <img class="w-100" src="<?php echo $item['item_image']; ?>">
                </div>
                <div class="col-md-8 item-desc">
                    <p><?php echo $item['item_desc']; ?></p>
                </div>
            </div>
        </div>  
    <?php    
    }
}


if($type == 'helicopter_item') {
    $sql = "SELECT * FROM helicopter_item WHERE id=" . $id;
    $items = $conn->query($sql);
    while($item = $items->fetch_assoc()) { ?>
        <div class="panel-body p-xl-4 p-md-4 p-2 bg-white br-rounded">
            <div class="p-2 row" id="item_details">
                <div class="col-md-4">
                    <img class="w-100" src="<?php echo $item['item_image']; ?>">
                </div>
                <div class="col-md-8 item-desc">
                    <p><?php echo $item['item_desc']; ?></p>
                </div>
            </div>
        </div>  
    <?php    
    }
    
}


// echo json_encode($outdoor_items);