I have a problem with my PHP code saying that
"Notice: Undefined index"
since I am a beginner i am not getting well what is wrong exactly so please help me.
<?php 
    require_once 'core/init.php';
    $id = $_POST['id'];
    $id =(int)$id; 
    $sql ="SELECT * FROM products WHERE id = '$id'";
    $result = $db->query($sql);
    $product= mysqli_fetch_assoc($result);
    $brand_id = $product['brand'];
    $sql = "SELECT brand FROM brand WHERE id = '$brand_id'";
    $brand_query = $db->query($sql);
    $brand = mysqli_fetch_assoc($brand_query); 
?>
//index.php
<?php 
      require_once 'core/init.php';
      include 'includes/head.php';
      include 'includes/navigation.php';
      include 'includes/headerfull.php';
      include 'includes/leftbar.php';
      include 'includes/footer.php';      
      include 'includes/detailsmodal.php';
      $sql = "SELECT * FROM products WHERE featured = 1";
      $featured = $db->query($sql);
?>
        <!--main content-->
        <div class="col-md-8">          
        <div class="row">
        <h2 class="text-center">Feature products</h2>
        <?php while($product = mysqli_fetch_assoc($featured)) : ?>
        <div class="col-md-3 text-center"> 
            <h4><?= $product['title']; ?> </h4>
            <img src="<?= $product['image']; ?>" alt="<?= $product['title']; ?>" class="img-thumb" />
            <p class="list-price text-danger">List price:<s>$<?= $product['list_price']; ?></s></p>
            <p class="price">Our price :$<?= $product['price']; ?></p>
        <button type="button" class="btn btn-sm btn-success" onclick="detailsmodal(<?= $product['id']; ?>)">Details</button>
        </div>
        <?php endwhile ;?>
        </div>
    <footer class="text-center" id="footer">© copyright 2019</footer>
     </div>     
    <?php 
        include 'includes/rightsidebar.php';
        include 'includes/footer.php';
    ?>
Undefined index: id in C:\xampp\htdocs\tutorial\includes\detailsmodal.php on line 3
 
    