include "_header.php";
if(empty($cid))$cid=-1;
$sql="select CT_Name from countylist where CountyID=$cid";
$result=mysql_query($sql) or die(mysql_error().'
'.$sql);
if($rs=mysql_fetch_assoc($result)){
  $countyName=$rs['CT_Name'];
}
$result=mysql_query($sql) or die(mysql_error().'
'.$sql);
$list='';
DrawHeader($_VAR['PROJECT_LONG_NAME']." - Cemetery Index",'','Cemeteries','index, follow');
startFrame('100%');
?>
$sql="select CemID,trim(CemName) as CemName2,CT_Name,count(entryid) as qty from gravestone,cemeteries,countylist where ";
$sql.="CountyID=CID and cemCID=CID and CemName<>'' and cemeteryID=cemID and approved='Y' and CID=$cid ";
$sql.="group by CemID,CemName,CT_Name order by CemName";
$result=mysql_query($sql) or die(mysql_error().'
'.$sql);
$lastLetter='';
$openRow=false;
$list='';
$numrec=0;
while($rs=mysql_fetch_assoc($result)){
  $thisLetter=strtoupper(substr(trim($rs['CemName2']),0,1));
  if($lastLetter<>$thisLetter){
	if($openRow)echo "\n\n";
	$lastLetter=$thisLetter;
	print "| $thisLetter:  | ";
	print "";
	$openRow=true;
	$firstEntry=true;
  }
  $numrec++;
  $cemURL="{$rs['CemName2']} ({$rs['qty']}) ";
  if($firstEntry){
	print $cemURL;
	$firstEntry=false;
  } else {
	print ", $cemURL";
  }
}
?>
 | 
if($numrec==0)
  include "_navlinks.html";
?>
 
 include "_footer.php";?>