title: PHP: I can't get reset() to work on my nested MySQLi dataset
body: <p>It seems like this should be pretty straight forward, so I feel like I am missing something simple. I run two separate queries and they get assigned to an associative array variable.The queries run fine and the data is there. I am trying to iterate through one dataset inside the other dataset using while loops. It runs fine the first time through but I can't get the nested dataset to reset so I can iterate through it again. In the code and results seen below you can see that the data is indeed there because it gets skipped over by the conditional IF statement. Additionally, if I change the nested query from ascending to descending I get the second set of data and not the first (I only have two data points in the first query while I am creating and testing).</p>
  
  <p>It seems like the reset() function should do what I am looking for, but it doesn't accomplish anything. I hope I am just missing something really simple.</p>
  
  <p>I even tried setting the $rowDate array to a blank array and NULL both before and after the While loop to force it to refetch the data, but that did nothing as well.</p>
  
  <p>Code snippet:</p>
  
  <pre><code>    $studSet = mysqli_query($connection, $queryStud);
      confirmQuery($studSet);
  
      $dateSet = mysqli_query($connection, $queryDate);
      confirmQuery($dateSet);
  
      while ($rowStud = mysqli_fetch_assoc($studSet)) {
          $studID = $rowStud['ID'];
          $sFName = $rowStud['FName'];
          $sLName = $rowStud['LName'];
          $output .= "&lt;p&gt;" . $sFName . " " . $sLName;
          while ($rowDate = mysqli_fetch_assoc($dateSet)) {
              $output .= "&lt;br /&gt;" . current($rowDate) . "&amp;nbsp;&amp;nbsp;&amp;nbsp;"; //here strictly for debugging
              if ($studID == $rowDate['studentID']) {
                  $output .= $rowDate['timeStamp'];
              }
          }
          reset($rowDate);
          $output .= "&lt;/p&gt;";
          $output .= "current " . current($rowDate) . " element"; //here strictly for debugging
      }
  
      return $output;
  </code></pre>
  
  <p>Result:</p>
  
  <p><a href="https://i.stack.imgur.com/8getP.jpg" rel="nofollow"><img src="https://i.stack.imgur.com/8getP.jpg" alt="CodeResult"></a></p>
  
  <p>Thanks in advance for your help.</p>