I have a check box list of students and a search box in first php page .In ajax page I will get the search results .

But the problem is ,if user selected first search result and searched again selection on the first search is lost


How can I save selections on the first search ?I have tried to make selections in an session array but it is not working
PHP Code:
    //check list
        
$qry="select cand_id,name from candidate where inst_id=".$_SESSION['inst_id']."";
        
$res=$ob->select($qry,$connect);
        while(
$rw=pg_fetch_row($res))
        {
            
            echo
"<br><input type=\"checkbox\" name=\"check[]\" value=\"$rw[0]\">";echo$rw[1];echo"<br>" ;
        }
    
//Ajax page
    
if($ajaxData!="")
    {
                                    if(
$_SESSION['usertype_id']==1)
                                    {
                                    
$qry="select cand_id,name from candidate where name like'$dataup%'  ";
                                    
                                    }
                                    else if(
$_SESSION['usertype_id']==2)
                                    {
                                    
$qry="select cand_id,name from candidate where inst_id=".$_SESSION['inst_id']."
                                    and  name like'$dataup%' "
;
                                    }
                                    
$res=$ob->select($qry,$connect);
                                    
$words=array();
                                    
$count pg_num_rows($res);
                                    if(
$count>0)
                                    {
                                        
$i=0;
                                        
//echo"<div  style=\"width: 200px; height: 200px;overflow-y: auto;padding-top: 10px;padding-right: 0px;padding-bottom: 0.25in;\">";
                                        
while($rw=pg_fetch_row($res))
                                        {
                                            
$words[$i]=$rw[0];$i++;
                                            
                                            
                                        }

                                        
$_SESSION['checkAjax']=$words;//can_id array 
1. How do I use array $_SESSION['checkAjax'] for highlighting?
2. Why $_SESSION['checkAjax'] unset on each ajax call?
3. Just need change of color on selected student names