Please help me to do the process in php so that I get the data derived from a variable. In this case, I created a php file that serves to make xml file creation. Here I've got the data, namely channel, and I want every parent in that channel my child will enter data. Please see my code :\[code\]<?php$dbhost = "localhost";$dbuser = "root";$dbpass = "";$dbname = "db_epg";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 = $r['channel_name']; $xml .= "<channel>".$CN."</channel>"; } $xml .= "</timetable>"; $sxe = new SimpleXMLElement($xml); $sxe->asXML("epg.xml"); ?>\[/code\]And the result from my code is : http://s9.postimage.org/rjsodf9mn/result.pngIf I want to do a loop in each data channel will be no data on children, then what should I do?I've tried doing another query in this while section :\[code\]while($r = mysql_fetch_array($q)){$CN = $r['channel_name'];$xml .= "<channel>".$CN."</channel>"; $sql2 = "select * FROM epg where channel_name='".$CN."'";$q2 = mysql_query($sql2) or die(mysql_error());while($r2 = mysql_fetch_array($q2)){ $Mulai = date('H:i', strtotime($r2['waktu_mulai'])); $Selesai = date('H:i', strtotime($r2['waktu_akhir'])); $Title = $r2['judul']; $Desk = $r2['sinopsis']; $xml .= "<event start='".$Mulai."' end='".$Selesai."'>"; $xml .= "<title>".$Title."</title>"; $xml .= "<description>".$Desk."</description>"; $xml .= "</event>"; }}\[/code\]But I have failed. Can someone help me??