title: How to convert simple MySQL example to MySQLi object oriented style?
body: <p>How to convert this simple MySQL example to MySQLi object oriented style:</p>
  
  <pre><code>$query = mysql_query("SELECT id, name FROM fruits WHERE `group`=''");
  
  if ($query) {
      while ($row = mysql_fetch_array($query, MYSQL_ASSOC)) {
          echo $row['name'];
  
          $query2   = mysql_query("SELECT name FROM fruits WHERE `group`='{$row['id']}'");
  
          if (mysql_num_rows($query2)) {
              echo ':';
  
              while ($row2 = mysql_fetch_array($query2, MYSQL_ASSOC)) {
                  echo ' '. $row2['name'] . ',';
              }
              mysql_free_result($query2);
  
              echo '&lt;br&gt;';
          }
      }
      mysql_free_result($query);
  }
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>Berries: blueberry, raspberry, strawberry,
  Citrus: grapefruit, lime,
  Pear
  </code></pre>
  
  <p>Database structure <code>SELECT * FROM fruits</code>:</p>
  
  <pre><code>id   | group | name
  -------------------------
  03E7 |       | Berries
  0618 | 03E7  | blueberry
  051B | 03E7  | raspberry
  02AA | 03E7  | strawberry
  035F |       | Citrus
  07A5 | 035F  | grapefruit
  0633 | 035F  | lime
  05E1 |       | Pear
  </code></pre>