<?
	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>Page</strong></td>
    <td><strong>Off</strong></td>
    <td><strong>On</strong></td>
  </tr>
<?
	$query = "
	SELECT 
		t1.*, 
		(SELECT status FROM advert_page_link WHERE advert_id=".$_GET['advert_id']." AND page_id=t1.id) AS status 
	FROM 
		page AS t1 
	ORDER BY 
		t1.sequence ASC,
        t1.name ASC";
	fb($query);
	$mysqldb1->query($query);
	while ($page = $mysqldb1->fetchArray()) {
?>
  <tr>
    <td><? print $page['name']; ?></td>
    <td><input onClick="setAdvertPage(<? print $_GET['advert_id']; ?>, <? print $page['id']; ?>, 0)" name="<? print $page['name']; ?>" type="radio" value="0" <? if ($page['status'] == 0) { print 'checked'; } ?> /></td>
    <td><input onClick="setAdvertPage(<? print $_GET['advert_id']; ?>, <? print $page['id']; ?>, 1)" name="<? print $page['name']; ?>" type="radio" value="1" <? if ($page['status'] == 1) { print 'checked'; } ?> /></td>
  </tr>
<?
	}
?>  
</table>
<?
	$mysqldb1->close();
?>