Hi all,
on my applications main page, i have 12 dashboard items for quick gist of all the records. the user was seeing his dasboard depending on the roles assigned to him. also if the user is having multiple roles then there is a heirachy of roles and depending on that records are displayed for eg. if a user is having role of admin, certifier , quality manager then i first check if admin then show xxx records then if quality manager then show yyyy records and lastly if certifier then show zzzz records. and ofcourse if the user is having all the roles then admin's records (xxx) are displayed.

below is the code of one such dashboard. it will get you some idea:

Code:
// for loading number of open NC's
if($FullAccess=='1') { 
	$NCstmt =" exec get_all_OpenNC @Subprogram_ID ='0' ";
} else if ($isProgManager =='1') { 
	$NCstmt="exec get_all_OpenNC_for_Role @Role_ID ='3' , @User_ID ='$_SESSION[suserid]' , @Subprogram_ID ='0' ";
} else if ($isCertifier =='1' ) { 
	$NCstmt="exec get_all_OpenNC_for_Role_SubprogramCertifyingCompany @Role_ID ='4' , @User_ID ='$_SESSION[suserid]' , @Subprogram_ID ='0' ";
}else if ($isAssistant =='1' ) { 
	$NCstmt="exec get_all_OpenNC_for_Role_SubprogramCertifyingCompany @Role_ID ='5' , @User_ID ='$_SESSION[suserid]' , @Subprogram_ID ='0' ";
}else if ($isLeadAuditor =='1' ) { 
	$NCstmt="exec get_all_OpenNC_for_Role_SubprogramCertifyingCompany @Role_ID ='6' , @User_ID ='$_SESSION[suserid]' , @Subprogram_ID ='0' ";
}else if ($isAuditor =='1' ) { 
	$NCstmt="exec get_all_OpenNC_for_Role_SubprogramCertifyingCompany @Role_ID ='7' , @User_ID ='$_SESSION[suserid]' , @Subprogram_ID ='0' ";
}else if ($isInspector =='1' ) { 
	$NCstmt="exec get_all_OpenNC_for_Role_SubprogramCertifyingCompany @Role_ID ='8' , @User_ID ='$_SESSION[suserid]' , @Subprogram_ID ='0' ";
} else {
	$NCstmt="";
}
//print $NCstmt;
$CntOpenNC=GetNumRows($NCstmt, $db);
in this ways number of records are diplayed to the user. onclick of the number of records i actually open a modal message box and load the actual data.

Now all of a sudden the requirement is show all the distinct records to the user. that is if a user is a superuser he will see all the records that is unique of (xxxx , yyyy , zzzz). if he is certifier and admin he will see unqiue of (xxxx , zzzzz). already the page is taking good enough of time to load. if i do array_merge i will be again taxing the page too much.

how can i do it without much alteration in code or else i will have to revamp the page again.

Thanks in advance