<?
	require_once('../include/user.php');
	require_once('../include/mysql.php');
	require_once('../include/functions.php');
	require_once('../include/fb.php');
	
	ob_start();
	
	// SETUP MYSQL HANDLERS
	$mysqldb1 = new mysql($host, $user, $pswd, $db); $mysqldb1->connect(); $mysqldb1->select();
	
?>

<table border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td><strong>Category</strong></td>
    <td><strong>Off</strong></td>
    <td><strong>On</strong></td>
  </tr>
<?
	$query = "
	SELECT 
		t1.*, 
		(SELECT status FROM contact_category_link WHERE contact_id=".$_GET['contact_id']." AND contact_category_id=t1.id) AS status 
	FROM 
		contact_category AS t1 
	ORDER BY 
		t1.name ASC";
	fb($query);
	$mysqldb1->query($query);
	while ($contact_category = $mysqldb1->fetchArray()) {
?>
  <tr>
    <td><? print $contact_category['name']; ?></td>
    <td><input onClick="setContactCategory(<? print $_GET['contact_id']; ?>, <? print $contact_category['id']; ?>, 0)" name="<? print $contact_category['name']; ?>" type="radio" value="0" <? if ($contact_category['status'] == 0) { print 'checked'; } ?> /></td>
    <td><input onClick="setContactCategory(<? print $_GET['contact_id']; ?>, <? print $contact_category['id']; ?>, 1)" name="<? print $contact_category['name']; ?>" type="radio" value="1" <? if ($contact_category['status'] == 1) { print 'checked'; } ?> /></td>
  </tr>
<?
	}
?>  
</table>