Normally you'd use a SQL query of the form:
select id from table where id not in (select id from another table)
But you're likely using MySQL. MySQL uses an alternative syntax to get around not having subselects:
select t1.id
FROM t1
LEFT JOIN t2
ON t1.id=t2.id
WHERE t2.id
IS NULL;
Something like should be able to give you what you want without having to do it in PHP.
However, if you still want to do it in PHP, what you do is basically like this:
$query1 = "select id from t1";
$res1 = mysql_query($query1);
$count1 mysql_num_rows($res1);
for ($i=0;$i<$count1;$i++){
$id1[]=mysql_result($res1,$i,'id');
}
$query2 = "select id from t2";
$res2 = mysql_query($query2);
$count2 mysql_num_rows($res2);
for ($i=0;$i<$count2;$i++){
$id2[]=mysql_result($res2,$i,'id');
}
print implode(":",array_diff($id1,$id2));