title: How to dynamically populate modal using PHP where the modal is part of a div created through a PHP loop?
body: <p>I have a PHP while loop that creates a <code>&lt;div&gt;</code> for every row in the SQL table. Within each <code>&lt;div&gt;</code> there is a button to open a modal, that also needs to be populated dynamically in context to each row.</p>
  <p>While I can populate the <code>&lt;div&gt;</code>s based on row values, I am unable to populate the modals for the same. Every modal, even in different <code>&lt;div&gt;</code>s, shows the value only from the first row. How do I fix this?</p>
  <p><a href="https://i.stack.imgur.com/BK1oO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BK1oO.png" alt="First Row's value for every modal opened using the 'abstract' button" /></a></p>
  <h3>CODE is something like this:</h3>
  <pre><code>$sql = &quot;SELECT * FROM `something` WHERE 1;&quot;;
  $result = $conn-&gt;query($sql);
  if ($result-&gt;num_rows &gt; 0) {
  while($row = mysqli_fetch_array($result)) 
  {
    // HTML CREATE DIV
    // ADD BUTTON FOR THE MODAL
    // END HTML
  }
  </code></pre>