<?php
        
    
if ($_GET['viewsource']) {
       
highlight_file__FILE__ );
       exit;
    }
    

    if (!isset(
$_GET['type'])) {
      
$type "employees"// Default page
    
} else    {
        
$type $_GET['type'];
    }
    
    if (!isset(
$_GET['posnbr'])) {
      
$posnbr 7// Default page
    
} else    {
        
$posnbr $_GET['posnbr'];
    }

    
$i 0;
    
    
$dbh=mysql_connect ("localhost""mydb""mypwd") or die ('I cannot connect to the database because: ' mysql_error());
      
mysql_select_db ("mydb");
    if(
$type == 'manager')    {
        
$sql ' SELECT * FROM `orgdata` WHERE posnbr = ' $posnbr;
    } else    {
        
$sql 'SELECT * FROM `orgdata` WHERE reports_to = ' $posnbr ' AND posnbr != ' $posnbr;
    }
    
    
$result mysql_query($sql);
    
    
$data "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
    
$data .= "<query>";
    while(
$record mysql_fetch_object($result)){
        
$data .= "<row>";
            for (
$i 0$i mysql_num_fields($result); $i++) {
                
$veld mysql_field_name($result$i);
                
$data .= "<".$veld.">";
                if(!empty(
$record->$veld)){
                    
$data .= $record->$veld;
                }
                
$data .= "</".$veld.">";
            }
            
$data .= "</row>";
    }
    
$data .= "</query>";

    if(!
headers_sent()){
        
header("Content-Type: application/xml");
    }echo 
$data;mysql_free_result($result);?>