title: How do I write data into a mysqli database using a button
body: <p>Hello Im writing a voting system for fun. The idea is that you vote on a music playlist, therefor the most popular song by vote gets played next. The track names as well as number of votes are stored in a mysql database. I am able to read data from my database and displaying the track names in a row with a button next to it. But I cant figure out how to make the button update the number of votes the track next to it has.</p>
  
  <p>My database has a table called votecount with 3 columns called track_id track_name track_votes respectively. I havent included my update function below since it wont work at all and I suspect my fault lies with somewhere else.</p>
  
  <p>I think of using the track id in a way of determining which track it should update by +1 each time the button next to it is pressed.</p>
  
  <p>i have included connecting to the database in a separate file called connect.php</p>
  
  <pre><code>    &lt;?php
      include 'connect.php';
      $sql = &lt;&lt;&lt;SQL
          SELECT *
          FROM `votecount` 
      SQL;
      if(!$result = $conn-&gt;query($sql)){
          die('There was an error running the query [' . $db-&gt;error . ']');
      } 
      while($row = $result-&gt;fetch_assoc()){
          echo $row['track_name'] . " TotalVotes  ( " . $row['track_votes'] . " ) &lt;form action='test.php' method'post'&gt;
  &lt;input name='" . $row['track_name'] . "' type='submit' id='" . $row['track_id'] . "'value='vote'&gt;&lt;/input&gt;
  &lt;br/&gt;&lt;/form&gt;";   
  }
  ?&gt;
  </code></pre>
  
  <p>Any help will be greatly appreciated thanks in advance!</p>