PHP Output xml data

ramses3

New Member
I make an appearance timetable that takes data from a database. But in my case, I take the data directly to the file data *.xmlOr in other words I do the scheduling for periodic data collection.But this resulted in data that I show is not dynamic. because it can only read the file *. xml it. I want to create a function in php and xml data outpunya be like this :\[code\]<?phpheader("Content-type: text/xml");$dbhost = "localhost";$dbuser = "user";$dbpass = "pass";$dbname = "my_epg";mysql_connect($dbhost,$dbuser,$dbpass);mysql_select_db($dbname);include "Encoding.php";date_default_timezone_set("Asia/Jakarta");$DataTanggal = strip_tags(date("l, jS, F Y"));sql = "select distinct(channel_name) FROM epg";$q = mysql_query($sql) or die(mysql_error());$xml = "<timetable start='00:00' end='24:00' title='".$DataTanggal."'>";while($r = mysql_fetch_array($q)){ $CN = htmlspecialchars(strip_tags($r['channel_name'])); $xml .= "<location name='".$CN."'>"; $sql2 = "select * FROM epg where channel_name='".$CN."'"; $q2 = mysql_query($sql2) or die(mysql_error());while($r2 = mysql_fetch_array($q2)){ $Mulai = htmlspecialchars(strip_tags(date('H:i', strtotime($r2['waktu_mulai'])))); $Selesai = htmlspecialchars(strip_tags(date('H:i', strtotime($r2['waktu_akhir'])))); $Title = htmlspecialchars(strip_tags($r2['judul'])); $Desk = htmlspecialchars(strip_tags($r2['sinopsis'])); $Encoding1 = Encoding::fixUTF8($TitleValid); $Encoding2 = Encoding::fixUTF8($DeskValid); $xml .= "<event start='".$MulaiValid."' end='".$SelesaiValid."'>"; $xml .= "<title>".$Encoding1."</title>"; $xml .= "<description>".$Encoding2."</description>"; $xml .= "</event>"; }$xml .= "</location>";}$xml .= "</timetable>";echo $xml;?>\[/code\]The results of this successful process php file and output the same as the *.xml accessed. Now the problem I use timetable.class.php to process this data.\[code\]public function createTimetable($url) { //Load xml file $xml = @simplexml_load_file($url, NULL, LIBXML_NOCDATA); if(!$xml) { echo 'Error: there is an error in your XML file: <a href="'.$url.'">'.$url.'</a>'; return; } if (strpos($url, 'http://') === 0 || strpos($url, 'https://') === 0 || strpos($url, 'ftp://') === 0) { echo 'Error: the path to your xml file may not start with "http://"'; return; } //Set the settings $this->setSettings($xml, $url); $this->writeHTML($xml); echo $this->mbencoding($this->output); return;}\[/code\]But this function can only be used to read data from an existing file (*.xml). Not dynamic php process.My question: How do I create a process on this class.php with a get or post the data to make it dynamic so I can access the link address that I have made ??the process of type xml echo?
 
Top