title: Alternative to mysql_field_name in mysqli
body: <p>I found this great function that converts MySQL queries into a XML page, and it looks like exactly what I need.  The only problem is that it uses MySQL, but that's not supported anymore, and it turns out one of the functions used isn't in MySQLi.  Does anyone know of an alternative to <code>mysql_field_name</code>?</p>
  <p>Here's the function that I found</p>
  <pre><code>function sqlToXml($queryResult, $rootElementName, $childElementName)
  { 
      $xmlData = &quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;ISO-8859-1\&quot; ?&gt;\n&quot;; 
      $xmlData .= &quot;&lt;&quot; . $rootElementName . &quot;&gt;&quot;;
   
      while($record = mysql_fetch_object($queryResult))
      { 
          /* Create the first child element */
          $xmlData .= &quot;&lt;&quot; . $childElementName . &quot;&gt;&quot;;
   
          for ($i = 0; $i &lt; mysql_num_fields($queryResult); $i++)
          { 
              $fieldName = mysql_field_name($queryResult, $i); 
   
              /* The child will take the name of the table column */
              $xmlData .= &quot;&lt;&quot; . $fieldName . &quot;&gt;&quot;;
   
              /* We set empty columns with NULL, or you could set 
                  it to '0' or a blank. */
              if(!empty($record-&gt;$fieldName))
                  $xmlData .= $record-&gt;$fieldName; 
              else
                  $xmlData .= &quot;null&quot;; 
   
              $xmlData .= &quot;&lt;/&quot; . $fieldName . &quot;&gt;&quot;; 
          } 
          $xmlData .= &quot;&lt;/&quot; . $childElementName . &quot;&gt;&quot;; 
      } 
      $xmlData .= &quot;&lt;/&quot; . $rootElementName . &quot;&gt;&quot;; 
   
      return $xmlData; 
  }
  </code></pre>
  <p>With the part in question is</p>
  <pre><code>$fieldName = mysql_field_name($queryResult, $i);
  </code></pre>