title: Passing 'id' from one php page to another php page
body: <p>I have two Mysql tables "addcoupons" with one column(couponvalue) and two rows with values 50 and 100. Another table "paytoget" with one column(usercouponinhand).
  I been trying to get all the rows in table-1 to a html page and pass the particular id of the row when user click on its value to anther php page where it inserts it in table-2. But unfortunately i have missed something which causing it to print id of first row irrespective of which value user clicks.</p>
  
  <p>My code goes as:
  Page 1 (user interaction page)</p>
  
  <pre><code>&lt;br&gt;
      &lt;?php                           
       $sql2 = "SELECT * FROM addcoupons WHERE customernumber = '$mobile' ";
      $result2 = $conn-&gt;query($sql2);
      if ($result2-&gt;num_rows &gt; 0) {                               
      $index = 0; 
      while($row2 = $result2-&gt;fetch_assoc()) { 
      $index++;                                  
  ?&gt;
  &lt;form action='usercouponadd.php?id=&lt;?php echo $row2['id'];?&gt;' method="post" id="usercouponadd"&gt;
  &lt;div&gt;
  &lt;h4 class="amount" form="usercouponadd"&gt; &lt;strong&gt;Rs. &lt;?php echo ($row2["couponvalue"]); ?&gt;&lt;/strong&gt;&lt;/h4&gt;
  &lt;button class="addbutton" form="usercouponadd" type="submit"&gt;&lt;span&gt; &lt;strong&gt;Add&lt;/strong&gt; &lt;/span&gt;&lt;/button&gt;
  &lt;/div&gt;
  &lt;hr class="line" align="left"&gt;
  &lt;?php     }
  } else {        
  echo "None";
  }   
  ?&gt;                                 
  &lt;/div&gt;
  </code></pre>
  
  <p>The second php page (insert into table-2)</p>
  
  <pre><code>$mobile = $_SESSION['mobile'];
  $date = date('M-d,Y H:i:s');
  $date2 = date('M-d,Y');
  $conn = new mysqli ($servername, $dbusername, $dbpassword, $dbname);
  if ($conn-&gt;connect_error) {
  die("Connection failed: " . $conn-&gt;connect_error);
  }
  $sql2 = "SELECT * FROM addcoupons WHERE id = " .$_GET["id"];
  $result2 = $conn-&gt;query($sql2);
  if ($result2-&gt;num_rows &gt; 0) {
  $index = 0;
  while($row2 = $result2-&gt;fetch_assoc()) { 
  $index++; 
  $usercouponinhand = $row2["couponvalue"];
  $sql = "INSERT INTO userpaytoget (usercouponinhand, mobile, date, date2)
  VALUES ('$usercouponinhand', '$mobile', '$date', '$date2')";
  if ($conn-&gt;query($sql) === TRUE) {
  echo '&lt;script language="javascript"&gt;';
  echo 'alert("coupon has been successfully added")';
  echo '&lt;/script&gt;';
  }
  else {
  echo "ERROR" . $sql . "&lt;br&gt;" . $conn-&gt;error;
  }
  }
  } else {
   echo " ";
  }
  $conn-&gt;close();
  </code></pre>
  
  <p>Table-1 "addcoupons"
  couponvalue
  50
  100</p>
  
  <p>Table-2 "paytoget"
  usercouponinhand
  xx
  xx</p>
  
  <p>Any Help is Appreciated.... </p>