I would like to know if it is possible to check multiple checkboxes with one click.

Say, for instance, that I have the following code:
PHP Code:
$Query mysql_query("SELECT * FROM relation");
if (
mysql_num_rows($Query)){
  while (
$rows mysql_fetch_array($Query)); {
  
extract($rows);
  print 
"<input type=checkbox value=$id name='sendmail'> $Name"
}

As you can see, I don't know exactly how many checkboxes will be printed. But I want one button to click, to select or deselect all the checkboxes.
And maybe, if it is possible, look at other database-info to check only the ones that are "$active = '1'". (for instance)

Could anyone help me with this one?
Thanx!