Jump to content

foreach loop in an array


me1000

Recommended Posts


array('CourseName'=>'','number'=>'','Complete'=>'','expired'=>"",'inProgress'=>"") // make the first row blank, 

foreach ($arrCourses as $strKey => $strRow) {


// Total Enrolled
$strQuery = "";
$intEnrolled = $Database->db->MyQuery($strQuery);
$counter['1'] = $counter['1'] + $intEnrolled;


// Completed
$strQuery = "";
$intCompleted = $Database->db->MyQuery($strQuery);
$counter['2'] = $counter['2'] + $intCompleted;

// Expired without Completing
$strQuery = "";
$intExpired = $Database->db->MyQuery($strQuery);
$counter['3'] = $counter['3'] + $intExpired;

// In Progress
$strQuery = "";
$intProgress = $Database->db->MyQuery($strQuery);
$counter['4'] = $counter['4'] + $intProgress;

,array('CourseName'=>$strRow['series'] ." ". $strRow['number'] ." (". $strRow['odid'].")",'number'=>$intEnrolled,'Complete'=>$intCompleted,'expired'=>$intExpired,'inProgress'=>$intProgress)

}

,array('CourseName'=>"TOTAL",'number'=>$counter['1'],'Complete'=>$counter['2'],'expired'=>$counter['3'],'inProgress'=>$counter['4'])


);

 

So basically I need the foreach loop to fill out the array, but from the php error im getting back Im going to guess that PHP doesnt let you do that.

 

So is there a way I can?

 

Thanks,

 

 

EDIT: By the way, I removed most of the queries prior to post because it is pointless to post them,

but there error im getting is

 

unexpected T_FOREACH, expecting ')'

so I know the problem is the loop!

Link to comment
Share on other sites

Your missing a semi colon

 

 

array('CourseName'=>'','number'=>'','Complete'=>'','expired'=>"",'inProgress'=>"") // make the first row blank, 

 

needs to be

 

array('CourseName'=>'','number'=>'','Complete'=>'','expired'=>"",'inProgress'=>""); // make the first row blank, 

 

Also you haven't set the array to a variable therefore this is doing nothing at all!

 

Regards

Liam

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.