I am having alot of trouble understanding how I would process this data in the format I need it in. Please let me know if I can explain anything better.
Controller: My first step is to pass the CompanyId from the session to my model for querying, the result is an array called $data['campaigns'].
I then am trying to put each of those CampaignIds into a different array called $ids[].
Lastly I want to to run each CampaignId through a query 7 times (one for each day of the week) and assign them to an array associated with the CampaignId.
// Assign query result to array to be used in view
$data['campaigns'] = $this->model_record->retrieve_campaign($CompanyId);
foreach($data['campaigns'] as $campaign) {
$ids[] = $campaign['CampaignId'];
}
foreach ($ids as $row) {
$data['camp'][] = $row;
for($i = 0; $i < 7; $i++) {
$data['numbers'][] = $this->model_record->week_data($i,$row, $StartDate);}
}
In my view, I would like to use a foreach loop to retrieve the seven results of each CampaignId and associate it with that CampaignId.
IE: CampaignId 1: 57,36,3,11,3,3,6 CampaignId 2: 3,98,193,98,21,33 etc..
I am not sure that I am constructing my controller correctly to achieve this and I have been trying to output this data in my view to no avail:
<?php foreach ($ids as $id_item){
echo "CampaignId " . $id_item;
foreach ($numbers as $number_item)
echo $number_item['MyCount'] . ",";}
?>