title: SQL partially works but needs a few WHERE clauses - I think
body: <p>How can I change this SQL to do the following:</p>
  
  <ol>
  <li>If user is not in table, add them. [THIS PART WORKS]</li>
  <li>If user IS in table AND <code>favourite_active = 0</code> change it to <code>favourite_active = 1</code>.</li>
  <li>If user is in table AND <code>favourite_active = 1</code> change it to <code>favourite_active = 0</code>.</li>
  </ol>
  
  <p>I need to add in WHERE clauses I think.</p>
  
  <pre><code>$result = mysql_query("SELECT * FROM tbl_favourites WHERE (user_id = '$who' AND favourite_id = '$usernum' AND favourite_active = '1')");
  
  // if user does not exist in favourites, add them
      if(mysql_num_rows($result) == 0) 
      {
           mysql_query("INSERT INTO tbl_favourites (user_id, favourite_id, favourite_active) VALUES ('$who', '$usernum', '1')");
          echo"You have added this user as a favourite";
      } 
  
  // if user does exist and favourite_active = 1 change to 0
      else {
          mysql_query("UPDATE tbl_favourites SET favourite_active='0' WHERE user_id='$who' AND favourite_id='$usernum'"); 
          echo"You have removed this user as a favourite";
      }
  
  // if user does NOT exist and favourite_active = 0 change to 1
      else {
          mysql_query("UPDATE tbl_favourites SET favourite_active='1' WHERE user_id='$who' AND favourite_id='$usernum'"); 
          echo"You have removed this user as a favourite";
      }
  </code></pre>