title: mysqli query to fetch row values without loop
body: <p>I am newbie and need help to resolve my issue.</p>
  
  <p>extract row values without loop.</p>
  
  <p>Table:</p>
  
  <pre><code> ----------------
    YEAR  | SALES
   ----------------
   2011  |     45
   2012  |     34
   2013  |     23
   2014  |     10
   2015  |     48
   ----------------
  </code></pre>
  
  <p>PHP code:</p>
  
  <pre><code>$sql = "SELECT YEAR FROM MyGuests";
  $result = $conn-&gt;query($sql);
  
  if ($result-&gt;num_rows &gt; 0) {
      // output data of each row
      while($row = $result-&gt;fetch_assoc()) {
          echo "YEAR: " . $row["YEAR"]. "&lt;br&gt;";
      }
  } else {
      echo "0 results";
  }
  </code></pre>
  
  <p>looking for solution to output the year value without loop , something similar below
  while loop prints all row values , but would like to extract individual year value from query and assign it to a variable</p>
  
  <pre><code>$year1 = $row["YEAR"]
  $year2 = $row["YEAR"]
  $year3 = $row["YEAR"]
  </code></pre>