title: PHP Increase value in XML
body: <p>What im trying to accomplish is to increase create and increase a value in XML.</p>
  
  <p>Code:</p>
  
  <pre><code>    // CONNECT TO DATABASE
      $SQL = "SELECT * FROM ads ORDER BY id DESC";
      $result = mysql_query($SQL);
  
      // OPEN XML
      $_xml = "&lt;?xml version='1.0' encoding='UTF-8' ?&gt;\n";
      $_xml .="&lt;ADS&gt;\n";
  
      while ($db_field = mysql_fetch_assoc($result)) {
  
      $_xml .=" &lt;AD&gt;\n";
      $_xml .="   &lt;ID&gt;&lt;![CDATA[" . $counter . "]]&gt;&lt;/ID&gt;\n";
      $_xml .="   &lt;TITLE&gt;&lt;![CDATA[" . $db_field['title'] . "]]&gt;&lt;/TITLE&gt;\n";
      $_xml .="   &lt;DESCRIPTION&gt;&lt;![CDATA[" . $db_field['description'] . "]]&gt;&lt;/DESCRIPTION&gt;\n";
      $_xml .="   &lt;EMAIL&gt;&lt;![CDATA[" . $db_field['email'] . "]]&gt;&lt;/EMAIL&gt;\n";
      $_xml .="   &lt;PHONE&gt;&lt;![CDATA[" . $db_field['phone'] . "]]&gt;&lt;/PHONE&gt;\n";
      $_xml .="   &lt;ADDRESS&gt;&lt;![CDATA[" . $db_field['address'] . "]]&gt;&lt;/ADDRESS&gt;\n";
      $_xml .="   &lt;ZIP_CODE&gt;&lt;![CDATA[" . $zipcode . "]]&gt;&lt;/ZIP_CODE&gt;\n";
      $_xml .="   &lt;LOCATION_COUNTRY&gt;&lt;![CDATA[" . $country . "]]&gt;&lt;/LOCATION_COUNTRY&gt;\n";
      $_xml .="   &lt;LOCATION_STATE&gt;&lt;![CDATA[" . $state . "]]&gt;&lt;/LOCATION_STATE&gt;\n";
      $_xml .="   &lt;LOCATION_CITY&gt;&lt;![CDATA[" . $city . "]]&gt;&lt;/LOCATION_CITY&gt;\n";
      $_xml .="   &lt;CATEGORY&gt;&lt;![CDATA[" . $db_field['category'] . "]]&gt;&lt;/CATEGORY&gt;\n";
      $_xml .="   &lt;BEDROOMS&gt;" . $db_field['bedrooms'] . "&lt;/BEDROOMS&gt;\n";
      $_xml .="   &lt;BATHROOMS&gt;" . $db_field['bathrooms'] . "&lt;/BATHROOMS&gt;\n";
      $_xml .="   &lt;PETS&gt;" . $db_field['pets'] . "&lt;/PETS&gt;\n";
      $_xml .="   &lt;BROKERFEE&gt;" . $broker . "&lt;/BROKERFEE&gt;\n";
      $_xml .="   &lt;SURFACE&gt;" . $db_field['surface'] . "&lt;/SURFACE&gt;\n";
      $_xml .="   &lt;IMAGE_URL&gt;&lt;![CDATA[" . $db_field['image_url'] . "]]&gt;&lt;/IMAGE_URL&gt;\n";
      $_xml .="   &lt;IMAGE_URL&gt;&lt;![CDATA[http://www.path to image]]&gt;&lt;/IMAGE_URL&gt;\n";
      $_xml .="   &lt;PRICE&gt;" . $db_field['price'] . "&lt;/PRICE&gt;\n";
      $_xml .="   &lt;CURRENCY&gt;" . $currency . "&lt;/CURRENCY&gt;\n";
      $_xml .=" &lt;/AD&gt;\n";
      } 
  
      // CLOSE XML
      $_xml .="&lt;/ADS&gt;";
  
      // ECHO XML DATA
      echo $_xml;
  </code></pre>
  
  <p>I want the "$counter" to provide a value of 1 and for every extra result it should at 1. Not my cup of joe, total noob when it comes to this. I can get a value from the mysql database, but requires that the first item should start with value 1.</p>