TO_DAYS(NOW() - INTERVAL 47 DAY) '; } $query = "SELECT DATE_FORMAT(c.added_date,'%Y%m%d-%H%i') AS datecreated, c.added_by AS creator, c.comment_id AS commentid, c.comment_category_id AS commentcategoryid, comp.name AS competitionname, comp.competition_id AS competitionid, cat.name AS commentcategoryname, c.fixture_id AS fixtureid, DATE_FORMAT(f.kick_off,'%Y-%m-%d %H:%i') AS kickoff, CONCAT(t1.name,'-v-',t2.name) AS fixturedetails, comment_details AS commentdetail, fe.team_id AS eventteamid, fe.event_time AS eventtime, fe.event_type AS eventtype, t1.team_id AS teamoneid, t2.team_id AS teamtwoid, t1.name AS teamonename, t2.name AS teamtwoname, f.team_one_score AS teamonescore, f.team_two_score AS teamtwoscore FROM betting.comment_category cat, betting.comment c LEFT JOIN ics.fixture f ON f.fixture_id=c.fixture_id LEFT JOIN ics.fixture_event fe ON fe.fixture_id=f.fixture_id AND fe.fixture_event_id=c.fixture_event_id LEFT JOIN ics.team t1 ON f.team_one_id=t1.team_id LEFT JOIN ics.team t2 ON f.team_two_id=t2.team_id LEFT JOIN ics.competition comp ON f.competition_id=comp.competition_id WHERE cat.comment_category_id=c.comment_category_id " . $fixtureparamsql . " ORDER BY c.added_date DESC"; $stmt = $mdb2->query($query); if (PEAR::isError($stmt)) { die($stmt->getMessage()); } $result = $stmt->fetchAll(); //global variables // display document in browser as plain text // for readability purposes // create doctype $dom = new DOMDocument("1.0","UTF-8"); $dom->formatOutput = true; // display document in browser as plain text // for readability purposes //header("Content-Type: text/plain"); header("Content-type: text/xml"); // create root element $root = $dom->createElement("feed"); $dom->appendChild($root); foreach($result as $key => $row) { //variables $commentid = $row['commentid']; $datecreated = $row['datecreated']; $commentcategoryid = $row['commentcategoryid']; $commentcategoryname = $row['commentcategoryname']; $eventtime = $row['eventtime']; $fixtureid = $row['fixtureid']; $fixturedetails = $row['fixturedetails']; $kickoff = $row['kickoff']; $competitionname = $row['competitionname']; $competitionid = $row['competitionid']; $teamoneid = $row['teamoneid']; $teamonename = $row['teamonename']; $teamonescore = $row['teamonescore']; $teamtwoid = $row['teamtwoid']; $teamtwoname = $row['teamtwoname']; $teamtwoscore = $row['teamtwoscore']; $commentdetail = $row['commentdetail']; //create the doc $scorefeed = $dom->createElement("scorefeed"); $root ->appendChild($scorefeed); $fixture = $dom->createElement("fixture"); $fixture->setAttribute('id',$fixtureid); $fixture->setAttribute('kick-off',$kickoff); $fixture->setAttribute('competitionid',$competitionid); $fixture->setAttribute('competitionname',$competitionname); $scorefeed-> appendChild($fixture); $hometeam = $dom->createElement("hometeam"); $homename = $dom->createTextNode($teamonename); $hometeam->setAttribute('id',$teamoneid); $hometeam->setAttribute('score',$teamonescore); $hometeam-> appendChild($homename); $fixture->appendChild($hometeam); $awayteam = $dom->createElement("awayteam"); $awayteam->setAttribute('id',$teamtwoid); $awayteam->setAttribute('score',$teamtwoscore); $awayname = $dom->createTextNode($teamtwoname); $awayteam-> appendChild($awayname); $fixture-> appendChild($awayteam); $matchupdate = $dom->createElement("matchupdate"); $matchcomment = $dom->createTextNode(utf8_encode($commentdetail)); $matchupdate->setAttribute('id',$commentid); $matchupdate->setAttribute('updatetime',$datecreated); $matchupdate->setAttribute('updatetypeid',$commentcategoryid); $matchupdate->setAttribute('updatetype',$commentcategoryname); $matchupdate->setAttribute('eventtime',$eventtime); $matchupdate -> appendChild($matchcomment); $fixture-> appendChild($matchupdate); $matchevents = $dom->createElement("matchevents"); $fixture-> appendChild($matchevents); } // save and display tree echo $dom->saveXML(); */ ?>