title: How to pass dynamic data from html data-attribute to a query using javascript?
body: <p>I have this button that hold data from database</p>
  
  <pre><code>     &lt;button title="View Conversation" type='button' class='btn btn-default btn-sm' data-toggle='modal' data-target='#viewConversationModal'
               data-empproj_id="&lt;?=$employeeproject['emproj_id'];?&gt;"
               data-empprojconvoid="&lt;?=$employeeproject['convofeed_id'];?&gt;"
               **data-empprojconvotoempid**="&lt;?=$employeeproject['toemployee_id'];?&gt;"
               **data-empprojconvofromemip**="&lt;?=$employeeproject['fromemployee_id'];?&gt;"
               data-empprojconvoconversation='"&lt;?=$employeeproject['conversation'];?&gt;"' &gt;     
       &lt;/button&gt;  
  </code></pre>
  
  <p>I need to use the data inside a query</p>
  
  <pre><code>    &lt;?php
       $toemployee =  data-empprojconvotoempid
       $fromemployee = data-empprojconvofromemip
  
      $convoQ = "SELECT * FROM projects as p 
      JOIN employeeprojects AS ep ON p.project_id = ep.project_id 
      JOIN employees AS e ON ep.employee_id = e.employee_id 
      JOIN clients AS c ON p.client_id = c.id 
      JOIN employeeprojects_conversation AS epc ON ep.employee_id = epc.toemployee_id
      WHERE epc.toemployee_id=**$toemployee** AND epc.fromemployee_id=**$fromemployee**"; 
     $displayConvoResult=mysqli_query($db, $convoQ);
  
  ;?&gt;
  </code></pre>
  
  <p>then make a while statement to display conversation in the modal</p>
  
  <pre><code>&lt;?php while($conversation=mysqli_fetch_array($displayConvoResult)){ ?&gt;
  &lt;div class='row convorow'&gt;
  &lt;div class='col-md-6 pull-left'&gt;
  &lt;p style="font-size: smaller;"&gt;Messenger A :&lt;/p&gt;
  &lt;textarea readonlyrows="4" cols="50"&gt;&lt;/textarea&gt;
  &lt;/div&gt;
  &lt;div class='col-md-6 pull-right'&gt;
  &lt;p style="font-size: smaller;"&gt;Messenger B :&lt;/p&gt;
  &lt;textarea readonlyrows="4" cols="50"&gt;&lt;/textarea&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;?php } ;?&gt;
  </code></pre>
  
  <p>script so far</p>
  
  <pre><code>$('#viewConversationModal').on('show.bs.modal', function(con){
  var button = $(con.relatedTarget);
  //get data
  var empprojconvotoempid = button.data('empprojconvotoempid');
  var empprojconvofromemip = button.data('empprojconvofromemip');
  });
  </code></pre>