title: Trouble sending attr int variable through ajax, to php, to db column
body: <p>Probably the longest way around though I think it originated from an example somewhere.
  The div's data-num, which I'm not sure I can use after reading about this some more, </p>
  
  <pre><code>div class='bill_like' data-num="1"
  </code></pre>
  
  <p>is used as a variable in the javascript</p>
  
  <pre><code> $(document).ready(function () { 
   $('.bill_like').click(function() {
   var TriggerClick = 0;
   var id = $(this).attr('data-num');
      if(TriggerClick==0){
          TriggerClick=1;
          request = $.ajax({
              type: 'POST',
              url: 'php/bill_like_up.php',
              data: id
          });
          $(this).children( '.vote_label' ).children('.vote_up_image').attr('src', "img/vote_up_green.png");
      }else{
          TriggerClick=0;
          request = $.ajax({
              type: 'POST',
              url: 'php/bill_like_down.php',
              data: id
          });
          $(this).children( '.vote_label' ).children('.vote_up_image').attr('src', "img/vote_up.png");
          };
      });
          return false;
  });
  </code></pre>
  
  <p>which then passes the data (assuming it does), to this .php.</p>
  
  <pre><code>&lt;?php
  $servername = "localhost";
  $username = "root";
  $password = "";
  $dbname = "test";
  $conn = new mysqli($servername, $username, $password, $dbname);
  if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
  }
   $id = $_POST['id'];
   $query = mysqli_query($conn, "SELECT id, bill_like FROM ausdb WHERE id='$id'");
   $sql = "UPDATE ausdb SET bill_like = bill_like + 1 WHERE id='$id'"; 
   $res = mysqli_query($conn, $sql) or trigger_error(mysqli_error()." in ".$sql);
  ?&gt;
  </code></pre>
  
  <p>The picture changes as it should but there is no update on the db. There are a number of variants on this for different elements in the html in the same file. Does the data-num value need to be different for each one, like a unique id? Should I be using an <code>&lt;a href=""&gt;</code> to access the javascript? I'm not sure why this isn't working. Would appreciate any help, thank you.</p>