<?php

$type = $_GET['type'];


$con = mysql_connect('localhost', 'root', 'Boom95z') or die(mysql_error());
mysql_select_db('orion9', $con);

$retStr = '';

if ($type == 'CL')
{
	$result = mysql_query("SELECT org_id, company_name FROM organisations where retired is null  and company_name != '' order by company_name asc");
	
	 while($row = mysql_fetch_array($result))
        {
            $org_id = $row['org_id'];
			$company_name = $row['company_name'];
				 
			$retStr = $retStr . "<option value='" . $org_id . "'>" . $company_name . "</option>";
        }
}

if ($type == 'CON')
{
	$result = mysql_query("SELECT con_id, representative FROM contractors where retired is null and representative != '' order by representative asc");
	
	 while($row = mysql_fetch_array($result))
        {
            $con_id = $row['con_id'];
			$representative = $row['representative'];
				 
			$retStr = $retStr . "<option value='" . $con_id . "'>" . $representative . "</option>";
        }
}

echo $retStr;


?>