title: PHP if statement only half works
body: <p>Ok I know this is something stupid I'm doing wrong. But i've been stuck on this for about an hour and cannot figure it out. I am really just starting to get into PHP so excuse the newbyness. Basically I am displaying a table of data from a MySQL database. But I want it so that users can essentially "Join" a "Campaign" and then only have the "Join" button display for campaigns that they have NOT joined. </p>
  
  <h3>Here is the code:</h3>
  
  <pre><code>&lt;?php
  //include db connect
    include ("/db_con.php");
  
  //campaign list function
    function listCampaigns() {
      //make connection global
      global $con;
  
      //set campaign variables
      $campaignquery = mysqli_query($con, "SELECT * FROM campaigns");
      while($row = mysqli_fetch_array($campaignquery )) {
          $ccampaignid = $row['campaignid'];
          $creator = $row['creator'];
          $name= $row['name'];
          $startdate = $row['startdate'];
  
          //set campaign_bookmark variables
          $userid = $_SESSION['userid'];
          $bmquery = mysqli_query($con, "SELECT * FROM campaign_bookmarks WHERE userid = $userid");
          while($bmrow = mysqli_fetch_array($bmquery)) {
              $bmuserid = $bmrow['userid'];
              $bmcampaignid = $bmrow['campaignid'];
          }
  
          //echo list in table
          echo "&lt;table border='1'&gt;";
          echo "&lt;tr&gt;";
          //display join button if userid in campaign bookmarks does not match session userid
          if($_SESSION['userid'] !== $bmuserid) {
              echo "&lt;form action='functions/campaign_bookmark.php' name='bookmarkCampaign' method='post'&gt; 
              &lt;input type='hidden' name='campaignid' value=" . $row['campaignid'] . "&gt;
              &lt;input type='submit' value='Join' onclick='clicked();'&gt;
              &lt;/form&gt;";
          }
          echo "&lt;/tr&gt; &lt;tr&gt;";
          echo "&lt;td&gt; Dungeon Master: &lt;/td&gt;";
          echo "&lt;td&gt;" . $creator . "&lt;/td&gt;"; //campaign creator/DM name
          echo "&lt;/tr&gt; &lt;tr&gt;";
          echo "&lt;td&gt; Campaign Name:&lt;/td&gt;";
          echo "&lt;td&gt;" . $name . "&lt;/td&gt;"; //campaign name
          echo "&lt;/tr&gt; &lt;tr&gt;";
          echo "&lt;td&gt; Start Date:&lt;/td&gt;";
          echo "&lt;td&gt;" . $startdate . "&lt;/td&gt;"; //campaign start date
          echo "&lt;/tr&gt;";
          echo "&lt;/table&gt;";
      } //end of outer while loop
    } //end of listCampaigns
  ?&gt;
  </code></pre>
  
  <p>The Join button does show up if a user has not joined any campaigns. When the Join button does show up, it does properly submit the data into the database via <code>campaign_bookmark.php</code> But once you have joined one campaign, then the Join button is gone for all of them. If any other info is needed please let me know what. Any help will be VERY appreciated. </p>