title: JQuery Function not response inside of php while loop
body: <p>here i want to passing the product_id value into addcart.php file through the jQuery Function.here 'Add Cart' button generated dynamically by php while loop. every button set as a invidual product id, there is fine until this..
  what's my problem is All Button pass the same value to addcart.php file when i clicked each one...i want to pass the value of individual one(button)..
  Please Give me a Solution... addcart.php just contain code like 
  "echo $_POST['pid']; only" </p>
  
  <pre><code>&lt;?php
  
  include('includes/db-config.php');
  
  $shop_id=$_GET['sid'];
  
  $get_product_q = mysql_query("select product from shops where sid = $shop_id");
  $get_product_f = mysql_fetch_array($get_product_q);
  $product_id    = explode(',', $get_product_f['product']);
  $count_product_id = count($product_id);
  
  for($i=0;$i&lt;$count_product_id;$i++){
  
  $get_product_q  = mysql_query("select * from products where pid = $i");
  $get_product_f  = mysql_fetch_array($get_product_q);
  $product_id = $get_product_f['pid'];
  ?&gt;
  
  
  &lt;script&gt;
  $(document).ready(function(){
  
    $('.but').click(function(){
  
  
      $.ajax({
  
          type: 'POST',
          url:"addcart.php",
          data : { pid : '&lt;?php echo $product_id?&gt;'},
          success:function(result){
        $("#div1").html(result);
  
      }});
  
    });
  
  });
  
  &lt;/script&gt;
  &lt;?php   
          $product_name        = $get_product_f['name'];
          $product_description = $get_product_f['description'];
          $product_price       = $get_product_f['price'];
  
  echo $product_name;
  echo '&lt;br&gt;';
  echo $product_description;
  echo '&lt;br&gt;';
  echo $product_price;
  echo '&lt;br&gt;';
  echo '&lt;input class="but" type="button" value="Add Cart" /&gt;';
  echo '&lt;br&gt;&lt;br&gt;';
  }
  ?&gt;
  
  
  
  &lt;div id="div1"&gt;&lt;/div&gt;
  </code></pre>