PHP Increase value in XML

ashrafadel

New Member
What im trying to accomplish is to increase create and increase a value in XML.Code:\[code\] // CONNECT TO DATABASE $SQL = "SELECT * FROM ads ORDER BY id DESC"; $result = mysql_query($SQL); // OPEN XML $_xml = "<?xml version='1.0' encoding='UTF-8' ?>\n"; $_xml .="<ADS>\n"; while ($db_field = mysql_fetch_assoc($result)) { $_xml .=" <AD>\n"; $_xml .=" <ID><![CDATA[" . $counter . "]]></ID>\n"; $_xml .=" <TITLE><![CDATA[" . $db_field['title'] . "]]></TITLE>\n"; $_xml .=" <DESCRIPTION><![CDATA[" . $db_field['description'] . "]]></DESCRIPTION>\n"; $_xml .=" <EMAIL><![CDATA[" . $db_field['email'] . "]]></EMAIL>\n"; $_xml .=" <PHONE><![CDATA[" . $db_field['phone'] . "]]></PHONE>\n"; $_xml .=" <ADDRESS><![CDATA[" . $db_field['address'] . "]]></ADDRESS>\n"; $_xml .=" <ZIP_CODE><![CDATA[" . $zipcode . "]]></ZIP_CODE>\n"; $_xml .=" <LOCATION_COUNTRY><![CDATA[" . $country . "]]></LOCATION_COUNTRY>\n"; $_xml .=" <LOCATION_STATE><![CDATA[" . $state . "]]></LOCATION_STATE>\n"; $_xml .=" <LOCATION_CITY><![CDATA[" . $city . "]]></LOCATION_CITY>\n"; $_xml .=" <CATEGORY><![CDATA[" . $db_field['category'] . "]]></CATEGORY>\n"; $_xml .=" <BEDROOMS>" . $db_field['bedrooms'] . "</BEDROOMS>\n"; $_xml .=" <BATHROOMS>" . $db_field['bathrooms'] . "</BATHROOMS>\n"; $_xml .=" <PETS>" . $db_field['pets'] . "</PETS>\n"; $_xml .=" <BROKERFEE>" . $broker . "</BROKERFEE>\n"; $_xml .=" <SURFACE>" . $db_field['surface'] . "</SURFACE>\n"; $_xml .=" <IMAGE_URL><![CDATA[" . $db_field['image_url'] . "]]></IMAGE_URL>\n"; $_xml .=" <IMAGE_URL><![CDATA[http://www.path to image]]></IMAGE_URL>\n"; $_xml .=" <PRICE>" . $db_field['price'] . "</PRICE>\n"; $_xml .=" <CURRENCY>" . $currency . "</CURRENCY>\n"; $_xml .=" </AD>\n"; } // CLOSE XML $_xml .="</ADS>"; // ECHO XML DATA echo $_xml;\[/code\]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.
 
Back
Top