title: PHP if else statement from two buttons
body: <p>I'm trying to make a simple vote script in PHP and need help. The problem I'm having is that I've created a form with two buttons, like and dislike, which correspond to an if else statement.</p>
  
  <p>If the like button is clicked do an update, else the dislike button was clicked do an update.</p>
  
  <p>Here is the code I have so far, there is more above it, but not necessary to my problem:</p>
  
  <pre><code>while($row = $q2-&gt;fetch()) 
          {
          $up_vote= $row['up_votes']; /*Current Up Votes*/
          $down_vote= $row['down_votes']; /* Current Down Votes*/
              echo '&lt;form method="post" action=""&gt;';
              echo '&lt;input type="button" id="up_vote" name="up_vote" value="Like" /&gt; OR';
              echo '&lt;input type="button" id="down_vote" name="down_vote" value="Dislike" /&gt;';
              echo '&lt;/form&gt;';
              echo round($row['rating'], 0);
              echo '% of voters Liked this';
              }
  
  
          $up_votes = $up_vote +1;/*$up_vote referes to original # of up_votes, $up_votes adds 1 to the number of votes*/
          $down_votes = $down_vote +1;/*$down_vote referes to original # of down_votes, $up_votes adds 1 to the number of votes*/
  
      if ($something);/*upvote clicked*/
      {
          $vote_update = "UPDATE images
                          SET up_votes:up_votes
                          WHERE vote_item_id: vote_item_id";
  
          $q3 = $conn-&gt; prepare($vote_update);
          $q3-&gt;execute(array(':up_votes'=&gt;$up_votes, /*$up_vote referes to original # of up_votes, $up_votes adds 1 to the number of votes*/
                             ':vote_item_id'=&gt;$current_vote_item_id));
  
          /* ALSO create INSERT INTO votes_done to track the user vote*/ 
      $conn = null;
      }       
      else ($something2);/*down vote clicked*/
      {
          $vote_update = "UPDATE images
                          SET down_votes:down_votes
                          WHERE vote_item_id: vote_item_id";
  
          $q3 = $conn-&gt; prepare($vote_update);
          $q3-&gt;execute(array(':down_votes'=&gt;$down_votes, /*$down_vote referes to original # of down_votes, $up_votes adds 1 to the number of votes*/
                             ':vote_item_id'=&gt;$current_vote_item_id));
          /* ALSO create INSERT INTO votes_done to track the user vote*/
      }   
  </code></pre>
  
  <p>What should the if and else statements look like? I'm not sure how to go about this, can't have two submits, should I have two different forms, one for each button? Either way how can I say if like was clicked go to if and run code, or if dislike was clicked go to else and run code?</p>
  
  <p>Thanks</p>