title: How can I get the data attribute from a php variable?
body: <p>I have a form that can delete records from a MySql database using ajax and jQuery. I'm trying to get the jQuery to only select the relevant record passed to it and not just delete the top row of records which it does at the moment. I think I need to get </p>
  
  <pre><code>&lt;div class="'.$id.'"&gt;
  </code></pre>
  
  <p>from my form and make it a data attribute that can be selected. Hope I'm making myself clear. Many thanks.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      //Delete Review
      $(document).ready(function(){
          //Need to get $id here.
          $(".deleteReview").click(function (e) {
              e.preventDefault();
              var username = $("#username").val();
              var film_id = $("#film_id").val();
              var id = $("#id").val();
  
              $.post('ajax_deleteReview.php', {
                  username: username,     
                  film_id: film_id, 
                  id: id
              }, function(data) {
                  $("#message").html(data);
                  $("#message").hide();
                  $("#message").fadeIn(500); 
                  $("#message").fadeOut(2500); 
              });
              return false;
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <pre class="lang-html prettyprint-override"><code>&lt;form&gt;
      &lt;div class="'.$id.'"&gt;
          &lt;input type="hidden" id="username" name="username" value="'. $username.'"&gt;
          &lt;input type="hidden" id="film_id" name="film_id" value="'.$film_id .'"&gt;
          &lt;input type="hidden" id="id" name="id" value="'.$id .'"&gt;
          &lt;button type="submit" id="" class="btn btn-danger btn-xs pull-right"&gt;delete&lt;/button&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>