Ok...
So I am trying to figure out why my loop repeats. I have a MySQL DB with:
id(key)(autofill)
year_id(eg. 2009)
date(2009-04-09)
title(story headline)
info(news story)
The link to the PHP (that outputs the XML code - so be sure to view source):
http://nlmphotography.net/MAIN/news/news.php
and the code for the php:
<?php
header("Content-type: text/xml");
$host = "xxxx";
$user = "xxxx";
$pass = "xxxx";
$database = "xxxx";
$linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host.");
mysql_select_db($database, $linkID) or die("Could not find database.");
$query = "SELECT DISTINCT year_id, date FROM news ORDER BY year_id";
$resultID = mysql_query($query, $linkID) or die("Data not found.");
$xml_output = "<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\"?>\n";
$xml_output .= "<newsmodule>\n";
while ($row = mysql_fetch_array($resultID))
{
$xml_output .= "\t<year name=\"" .date('Y', strtotime($row[date])). "\">\n";
$year_id = $row[0];
$subQuery = "select * from news where year_id ='" .$year_id. "' order by id DESC";
$res = mysql_query($subQuery);
while ($subRow = mysql_fetch_array($res))
{
$xml_output .= "\t\t<news>\n";
$xml_output .= "\t\t\t<date>" .date('M d', strtotime($subRow[date])). "</date>\n";
$xml_output .= "\t\t\t<title><![CDATA[" .$subRow["title"]. "]]></title>\n";
$xml_output .= "\t\t\t<info>\n";
$xml_output .= "\t\t\t\t<![CDATA[" .$subRow["info"]. "]]>\n";
$xml_output .= "\t\t\t</info>\n";
$xml_output .= "\t\t</news>\n";
}
$xml_output .= "\t</year>\n";
}
$xml_output .= "</newsmodule>";
echo $xml_output;
?>