Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $dbhost = "localhost";
- $dbuser = "berthowe_ulatih";
- $dbpass = "hcw!D3w3M7Lt";
- $dbname = "berthowe_latihan";
- mysql_connect($dbhost,$dbuser,$dbpass);
- mysql_select_db($dbname);
- $sql = "select distinct(channel_name) FROM epg";
- $q = mysql_query($sql) or die(mysql_error());
- $xml = "<timetable start='00:00' end='24:00' title='Friday, September 28th, 2011'>";
- while($r = mysql_fetch_array($q)){
- $CN = htmlspecialchars($r['channel_name']);
- $xml .= "<channel 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(date('H:i', strtotime($r2['waktu_mulai'])));
- $Selesai = htmlspecialchars(date('H:i', strtotime($r2['waktu_akhir'])));
- $Title = htmlspecialchars($r2['judul']);
- $Desk = htmlspecialchars($r2['sinopsis']);
- if($Mulai==""){
- $MulaiValid = "Kosong";
- }else{
- $MulaiValid = $Mulai;
- }
- if($Selesai==""){
- $SelesaiValid = "Kosong";
- }else{
- $SelesaiValid = $Selesai;
- }
- if($Title==""){
- $TitleValid = "Kosong";
- }else{
- $TitleValid = $Title;
- }
- if($Desk==""){
- $DeskValid = "Kosong";
- }else{
- $DeskValid = $Desk;
- }
- $xml .= "<event start='".$MulaiValid."' end='".$SelesaiValid."'>";
- $xml .= "<title>".$TitleValid."</title>";
- $xml .= "<description>".$DeskValid."</description>";
- $xml .= "</event>";
- }
- $xml .= "</channel>";
- }
- $xml .= "</timetable>";
- //print $xml;
- $sxe = new SimpleXMLElement($xml);
- $sxe->asXML("epg.xml");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement