I'm only revealing part of my script but you will notice a 2nd mysql call embeded in a while loop. The object is to pull data from the leads table and the notes associated with those leads. But I need to report the LAST signature and timestamp AS WELL as an array of ALL signatures and respective timestamps for that lead. This script takes 8 seconds to load like this since there are over 1000 leads to display. How can I make this faster? I thought of using a JOIN statement but not sure how Id go about doing this.

I appreciate your help.
PHP Code:
$lSQL "SELECT LID, FIRSTNAME, LASTNAME, EMAIL, PHONE, STATUS FROM leads WHERE leads.TOSALES = 1 AND STATUS = 1 ORDER BY STATUS ASC";
                
$lQRY mysql_query($lSQL);

                if (
mysql_num_rows($lQRY) > 1){
        
                    
$rowCnt "odd";
                    while (
$lOBJ mysql_fetch_object($lQRY)) {
                        
                        
$sigArray = array();
                        
$cSQL "SELECT SIGNATURE, DATE(TIMESTAMP) AS DATE FROM notes WHERE LEADID = '".$lOBJ->LID."' AND TYPE = 3 ORDER BY TIMESTAMP DESC";
                        
$cQRY mysql_query($cSQL);
                        if(
mysql_num_rows($cQRY) > 0) {
                            while(
$cOBJ mysql_fetch_object($cQRY)) {
                                
$cARR[] = $cOBJ;
                            }
                            
$lastContact '<span style="font-size: 14px;">'.$cARR[0]->DATE.'</span><br /><span style="font-size: 10px;">'.$cARR[0]->SIGNATURE.'</span>';
                            
                            
$sigArray array_map(function ($ar) {return $ar->SIGNATURE;}, $cARR);
                            
$noteCnt 1;
                        } else {
                            
$lastContact '';
                            
$noteCnt 0;
                        }
                        
$reps "";
                        if(
count($sigArray) > 0) {
                            
$sigs array_unique($sigArray);
                            foreach (
$sigs AS $i => $v) {
                                
$reps .= $v ", ";
                            }
                            
$reps rtrim($reps", ");
                            
$reps rtrim($reps);
                        } 
Also $sigArray keeps appending to itself instead of clearing out each lead.