'; $xml = ''; if( !isset( $_GET['Category'] ) ) { $top .= "Category "; while ($row = mysql_fetch_assoc($result)){ if($row['category']=='PublishLike'){ $first = " CategoryID ".$row['catid']." CategoryName ".$row['category']." PublisherId ".$row['publisherid']." "; }else{ $xml .= " CategoryID ".$row['catid']." CategoryName ".$row['category']." PublisherId ".$row['publisherid']." "; } } } else { $top .= "SubCategory "; while ( ( $row = mysql_fetch_assoc($result) ) !== false ) { if( $row['category'] == 'PublishLike') { $first .= " SubCategoryID ".$row['subcatid']." CategoryID ".$row['catid']." CategoryName ".$row['category']." SubCategoryName ".$row['subcategory']." PublisherId ".$row['publisherid']." "; } else { $xml .= " SubCategoryID ".$row['subcatid']." CategoryID ".$row['catid']." CategoryName ".$row['category']." SubCategoryName ".$row['subcategory']." PublisherId ".$row['publisherid']." "; } } } $xml .= " "; echo $top.$first.$xml; ?>