title: getting value from column for each field, but it returns NULL?
body: <p>I am trying to get the value of "rounds" from the column rounds in my db. So, I want to get the value (1-5) of a field for each debate/post. Based on the value/number it is supposed to display a different thing. When I supposedly get the value It says NULL even though the value in the db field for that debate/post is 4. This is not just that debate, but this occurs for all of them. How can I get the actual value of the field in the column and assign it to a variable called $rounds . This variable needs to have the value for each debate made, not just that debate.</p>
  
  <pre><code>$servername = "";
  $username = "";
  $password = "";
  $dbname = "";
  
  $con = new mysqli($servername, $username, $password, $dbname);
  
  if ($con-&gt;connect_error) {
      die("Connection failed: " . $con-&gt;connect_error);
  }
  else{
    $sql = "SELECT rounds FROM vf_Discussion";
      $result = $con-&gt;query($sql);
      $allRounds = $result-&gt;fetch_row();
      $rounds = $allRounds[0];
  
      var_dump($rounds);   
  }
  mysqli_close($con);
  ?&gt;
  
  &lt;?php    
        $rounds1 =        '&lt;h2 class="CommentHeading"&gt;Round 1 (Pro)&lt;/h2&gt; &lt;br&gt; &lt;h2 class="CommentHeading"&gt;Round 1 (Con) &lt;/h2&gt;';
        $rounds2 =    '&lt;h2 class="CommentHeading"&gt;Round 2 (Pro)&lt;/h2&gt; &lt;br&gt; &lt;h2 class="CommentHeading"&gt;Round 2 (Con)&lt;/h2&gt;';
        $rounds3 =    '&lt;h2 class="CommentHeading"&gt;Round 3 (Pro)&lt;/h2&gt; &lt;br&gt; &lt;h2 class="CommentHeading"&gt;Round 3 (Con)&lt;/h2&gt;';
        $rounds4 =        '&lt;h2 class="CommentHeading"&gt;Round 4 (Pro)&lt;/h2&gt; &lt;br&gt; &lt;h2 class="CommentHeading"&gt;Round 4 (Con)&lt;/h2&gt;';
        $rounds5 =    '&lt;h2 class="CommentHeading"&gt;Round 5 (Pro)&lt;/h2&gt; &lt;br&gt; &lt;h2 class="CommentHeading"&gt;Round 5 (Con)&lt;/h2&gt;';
         ?&gt;
  
  &lt;?php
      foreach($allRounds as $rounds) {
          if ($rounds == 1) {
              echo $rounds1;
              foreach ($Sender-&gt;Data('Answers') as $Row) {
                  $Sender-&gt;EventArguments['Comment'] = $Row;
                  WriteComment($Row, $Sender, Gdn::Session(), 0);
              }
          }
          if ($rounds == 2) {
              echo $rounds1;
              echo $rounds2;
              foreach ($Sender-&gt;Data('Answers') as $Row) {
                  $Sender-&gt;EventArguments['Comment'] = $Row;
                  WriteComment($Row, $Sender, Gdn::Session(), 0);
              }
          }
          if ($rounds == 3) {
              echo $rounds1;
              echo $rounds2;
              echo $rounds3;
              foreach ($Sender-&gt;Data('Answers') as $Row) {
                  $Sender-&gt;EventArguments['Comment'] = $Row;
                  WriteComment($Row, $Sender, Gdn::Session(), 0);
              }
          }
          if ($rounds == 4) {
              echo $rounds1;
              echo $rounds2;
              echo $rounds3;
              echo $rounds4;
              foreach ($Sender-&gt;Data('Answers') as $Row) {
                  $Sender-&gt;EventArguments['Comment'] = $Row;
                  WriteComment($Row, $Sender, Gdn::Session(), 0);
              }
          }
          if ($rounds == 5) {
              echo $rounds1;
              echo $rounds2;
              echo $rounds3;
              echo $rounds4;
              echo $rounds5;
              foreach ($Sender-&gt;Data('Answers') as $Row) {
                  $Sender-&gt;EventArguments['Comment'] = $Row;
                  WriteComment($Row, $Sender, Gdn::Session(), 0);
          }
      }
  
  }
  ?&gt; 
  </code></pre>