I currently have a problem with jQuery & PHP.
When I try to target on click on class ".id_annonce" from generated php code it does not grab me the exact value I clicked but another one and it's always fix, input hidden value is 18 when it should be 19 or 20.
Jquery code :
var commander = $(this).val();
  var beta = $('body .id_annonce').val();
  window.location.href = 'panier.php?id='+ commander +'?annonce='+ beta + ''; 
My php code :
require 'produits.php';
$pro = new produits;
$coll = $pro->getAllproduits();
foreach ($coll as $key => $value) {
    echo '<div class="card-body  my-3 border-top" >
        <img src="img/resize.jpg" class="card-img-top  " style="height:88px;width:88px;margin-left:20px;float:right;" alt="...">   
        <h3 class="card-title p-2" style="font-size:10px;font-style:none;font-weight:600;"><strong>Ajouté Le : </strong> ' . $value['date_ajout'] . '</h3>
        <div class="d-flex flex-row">
        <h6 class="card-subtitle p-2  mb-2  text-muted"><strong>Varieté : </strong>' . $value["variete"] . '</h6>
        <h6 class="card-subtitle p-2 mb-2  text-muted" style="font-style:none;"><strong>Especes :  </strong>5000 tonnes</h6></div>
        <div class="d-flex flex-row">
        <h6 class="card-subtitle p-2  text-muted"><strong>Classe : </strong>' . $value["classes"] . '</h6>
        <h6 class="card-subtitle p-2  text-muted" style="font-style:none;"><strong> Quantité :  </strong>' . $value["quantite"] . '</h6></div>
        <h6 class="card-subtitle p-2 mb-2 mt-1 text-muted" style="font-style:none;float:right;font-size:24px;">    <strong>Prix : </strong> ' . $value["prix"] . 'DA/kg</h6> 
        <div class="d-flex flex-row justify-content-start" style="margin-top:50px;">
        <div class="p-1"> <button  class="details" value="' . $value["id"] . '" style="border:none;background:none;"> <i class="fa fa-info-circle fa-2x  pr-2 text-success"></i></button></div>
        <div class="p-1">
        <input type="hidden"  value="' . $value["id"] . '"  class="id_annonce">
        <button class="commander btn btn-md  btn-outline-dark " value="' . $value["id_commande"] . '"> Commander <i class="fa fa-shopping-cart  pr-2 "></i></button></div>
        <div class="p-1">  
        <button  value="' . $value["Interesser"] . '" class="interesser btn  btn-md text-dark" style="border-color:green;font-weight:600;">Interesser(' . $value["Interesser"] . ')</button></div></div></div>';
}
 
     
     
    