adding and array within an array

9 posts by 3 authors in: Forums > CMS Builder
Last Post: July 28, 2014   (RSS)

By nmsinc - July 27, 2014 - edited: July 27, 2014

I have a field labeled "score" located in a record that I need to extract while using the array listed below and I'm stumped. I also need to add all of the scores together as they are pulled and divide the total by the number total number of extractions!

Thanks for any help - nmsinc

      $total2 = 0;
      print "<td align='center'><font face='Verdana' font size='1'>FINISHED RECEIVED</font></td>\n";
      foreach (range(1,12) as $m) {
        $countWhere2  = "YEAR(createdDate) = $yyyy AND MONTH(createdDate) = $m AND $where2";
        $recordCount2 = mysql_count($tableName, $countWhere2);
        $total2 = $recordCount2 + $total2;
        print "<td align='center'><font face='Verdana' font size='1'>$recordCount2</font></td>\n";
      }
        print "<td align='center'><font face='Verdana' font size='1'>$total2</font></td>\n";
        print "</tr>\n";

nmsinc

By claire - July 28, 2014

I think we need to see more of the code here - normally you'd just use as many foreach loops as needed to add everything up together.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By nmsinc - July 28, 2014 - edited: July 28, 2014

HI Claire,

A foreach statement will not work because of the number of records that will be read - the file I'm attaching is an inventory program that is used to count the records based on the users preference from one to seven years. It will count the number of records by date and then calculates percentages month-by-month.

Records that have been marked as finished also contain a score from 400 to 1000. I need to capture the scores on each record that match the $where statement without the script timing out or exceeding the php cache settings.

Any suggestions would be appreciated.

Thanks - nmsinc

nmsinc

By claire - July 28, 2014

Okay, roughly how many records per query are you expecting for each user?

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By nmsinc - July 28, 2014

1000, to 10,000 per month x 12 months! - currently using a foreach(range(1,12)  statement!

nmsinc

By claire - July 28, 2014

Yeah, that's a bit excessive for a set of loops.

Basically this is a database problem, not a PHP problem. It's beyond what the CMSBuilder functions can do, but it can probably be solved with some custom SQL queries and table optimization. Unfortunately that puts it outside the scope of forum support - there's really no quick fix for this kind of issue.

If you want us to implement this for you, just send an email to consulting@interactivetools.com and link to this thread, we'll get you sorted.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By claire - July 28, 2014

Are you using this form? https://www.interactivetools.com/support/email_support_form.php

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By ross - July 28, 2014

Hi there.

Got your email this time :)! Thanks for sending it again.  I am going to review this thread and get back to you  (via email) with my ideas as soon as I can.

In the meantime, for anyone else following along in this thread, this is a good time to remind you all that if you don't receive the auto confirmation email when sending in support or consulting requests, we might not have received your email. I recommend you post back to your thread just as a notification you sent an email so we know to be looking for it.

Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/