i am trying to output statistics of calls made by agents across all dialing campaigns called for the day. there are multiple campaigns, currently 3, dialed in a day. I get the campaign data from a table name that changes by campaign like so custom_16546546 and custom_1564654. I run a query to get the numeric part of the column name then pass that as a variable in to another query that outputs the users statistics. This is where it only displays data from what i can tell is the last query loops information. I have displayed the array data from the first query to confirm the table names are being stored and it looks fine.
    $today = "2013-05-29";
$customquery = "SELECT distinct( entry_list_id) FROM vicidial_list where entry_list_id > 0 and last_local_call_time between '$today 00:00:00' and '$today 23:59:59';" ;
$customresult = mysql_query($customquery) or die(mysql_error());
$customrows = mysql_num_rows($customresult);
        while ($customrowResult = mysql_fetch_array($customresult)) 
                {
                $customID[] = $customrowResult["entry_list_id"];
                }
$z = 0;
if(!$customID){
//echo " Please Select a valid date range: ".$today. " - ".$today." is not valid" ;
}else{
while($z<$customrows)
{
$query = "SELECT 
            vicidial_users.user,
            vicidial_users.full_name,
            vicidial_log.list_id,
            COUNT(CASE WHEN (vicidial_log.status = 'SALE') THEN 1 ELSE null END) as sumcountSamnt,
            COUNT(CASE WHEN (vicidial_log.status = 'SALE' AND custom_$customID[$z].up_amt <> '') THEN 1 ELSE null END) as sumcountupAmnt,
            COUNT(CASE WHEN (vicidial_log.status = 'SALE' AND custom_$customID[$z].cc_num <> '') THEN 1 ELSE null END) as sumccverifiedcountAmnt,
            COUNT(CASE WHEN (vicidial_log.status = 'SALE' AND custom_$customID[$z].bank_act <> '') THEN 1 ELSE null END) as sumbankverifiedcountAmnt,
            SUM(CASE WHEN (vicidial_log.status = 'SALE' AND custom_$customID[$z].cc_num <> '') THEN custom_$customID[$z].s_amount ELSE null END) as sumccverifiedAmnt,
            SUM(CASE WHEN (vicidial_log.status = 'SALE' AND custom_$customID[$z].bank_act <> '') THEN custom_$customID[$z].s_amount ELSE null END) as sumbankverifiedAmnt,
            SUM(CASE WHEN (vicidial_log.status = 'SALE') THEN custom_$customID[$z].d_amt ELSE null END) as sumDamnt,
            SUM(CASE WHEN (vicidial_log.status = 'SALE') THEN custom_$customID[$z].up_amt ELSE null END) as sumUpamnt,
            SUM(CASE WHEN (vicidial_log.status = 'SALE') THEN custom_$customID[$z].md_amt ELSE null END) as sumMdamnt,
            SUM(CASE WHEN (vicidial_log.status = 'SALE') THEN custom_$customID[$z].s_amount ELSE null END) as sumSamnt
        FROM
            vicidial_log
        INNER JOIN
            vicidial_users
        ON
            (vicidial_log.user = vicidial_users.user)
        INNER JOIN
            custom_$customID[$z]
        ON
            (vicidial_log.lead_id = custom_$customID[$z].lead_id)
        WHERE 
            call_date
        BETWEEN
            '$today 00:00:00'
        AND
            '$today 23:59:59'
        AND
            vicidial_log.user != 'VDAD'
        AND
            vicidial_users.user_group != 'TX-Training'
        GROUP BY
            vicidial_log.user, vicidial_log.campaign_id
        ";
//This query is used to sum loop data data 
$queryResult = mysql_query($query) or die(mysql_error());    //This line perfomrs query error handling 
$z++;
}
here is a snippet of how the data is displayed
    $result = mysql_query($query) or die(mysql_error());
    while ($row = mysql_fetch_assoc($result)) 
 {   
     echo "<tr>\n";
  //--fullname and userID 
     echo "<td> ".$row["full_name"]. " - ".$row["user"]."</td>\n";
  //Agent total sales amount
             if ($row["sumcountSamnt"] == '0') {
    echo "<td>$nosalestxt</td>\n";
    } else {
     echo "<td> $".$row["sumSamnt"]."</td>\n";
     }
    }
So i want to be able to display a sum total of data for each user from all the campaigns they dialed from.
Thanks in advance for your help
EDIT: i use &row from a while loop to output the data and yes Chris i would like to store it an array, but i guess im just missing it, thanks again
 
    