Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

First off, thank you for taking the time to read this--I am still beginning at PHP and CI!

In my controller I have the following:

    // Retrieves all CampaignId from query in array
    $data['campaigns'] = $this->model_record->retrieve_campaign($CompanyId);

    // Grab each CampaignId from array
    foreach($data['campaigns'] as $campaign) {
        $ids[] = $campaign['CampaignId'];
    }

    // Foreach CampaignId, run query 7 times for each day of week
    foreach ($ids as $row) {
        for($i = 0; $i < 7; $i++) {
        $data['ids'][] = $this->model_record->week_data($i,$row, $StartDate); }
    }

This is working great to return all the values to my view as such:

<?php foreach($ids as $row):
echo $row['MyCount'] . ",";
endforeach?>

This returns all values as integers one after another. My question is, how can I return these values 7 at a time along their corresponding CampaignId? I am trying to return these values in a javascript that creates a line chart based on each campaign.

I am attempting to get the following in my view:

For every CampaignId:

[ { fillColor : 'rgba(151,187,205,0.5)',
        strokeColor : 'rgba(151,187,205,1)',
        pointColor : 'rgba(151,187,205,1)',
        pointStrokeColor : '#fff',
        data : [ <?php foreach($ids as $row): echo $row['MyCount'] . ","; endforeach?>]
            }]};

Thank you for any suggestions!

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.