Jump to content

w2pc

New Members
  • Posts

    9
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

w2pc's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok one last question on this . How would i add additional fields to this? I know how in the sql. but in this, $money[$r['Name']] += substr($r['amount'],1); Say I want to add account number
  2. Sorry I was being a retard and did not change $money[$r['client name']] += substr($r['total'],1); to $money[$r['client name']] += substr($r['amount'],1); which is the correct column name
  3. Got me one step closer. my print_r($r) returns right Array ( [FirstName] => SUSAN ANNETTE [amount] => $218.10 ) Array ( [FirstName] => SUSAN ANNETTE [amount] => $217.86 ) Array ( [FirstName] => SUSAN ANNETTE [amount] => $137.74 ) With many more records. And I used the format for $xx.xx but it returns as follows Customer SUSAN ANNETTE owes a total of $0 Customer MICHAEL MARK owes a total of $0 Customer PAMELA BROOKS owes a total of $0 Your being a great help than you.
  4. well needless to say I took over a dev spot of someone who thought they were SUPER but with that still being said, I can't just go change the db right now but I am in the process of changing a lot of projects and db structures 1 at a time.. Right now I just have to make do. I can get all the records I need with a join, but have to figure how to split my results into groups by customer # and then cal the sum of that customer
  5. I did not design the database, That is they way it was when I took it over. I know money should actually be stored as a dec
  6. This did not work. Also let me clearify that the amount field in table 2 is a varchar and not a dec as it looks like this $33,234.39; I know a way I can get all the records I need but then how would i loop through them and calculate the total for each customer.. example: customer 1, acct #1, $13.02 customer 1, acct #1, $345.02 customer 1, acct #1, $1,353.02 customer2 , acct #2, $2.25 customer 2, acct #2, $11.25 customer2 , acct #2, $11.24 customer2 , acct #2, $12.50 customer2 , acct #2, $14.60 customer3 , acct #3, $4,521.25 This would be all records but i just want sum for customer1 -> total of all 3 records customer2 -> total of all 5 records customer3 -> total of the 1 record
  7. Setup: Mysql table 1: acct#, client name, status(active/not active), Starting balance, ending balance Mysql table 2: acct#, invoice amount, invoice date, total how do i select all customers that are Active, and the starting balance != ending balance and then get the total for all invoices for that customer where the invoice date is between 2010-01-01 and 2010-03-01 Basically my out put needs to look like this. Customer name, Total of all invoices for customer john doe, $10,564.21 Susy Scott, $158.02 Bang Head, $837,294.85 Customer can have multiple invoices within the given date range. But I only need the total for all the invoices for each customer added up and echo'ed. Quickness is also a factor on the query and echo. Thank you for your valuable time.
  8. I have the following functions that i need to only loop if the conditions are true. The conditions are based on a 2 preg_match: # if so it should loop between Dispursments that start between # preg_match('/W2PC/',$cell->nodeValue); # and the next # preg_match('/TOTAL FOR W2PC/',$cell->nodeValue); The loop should start at the first and end when it identifies the second preg_match. While the conditions are true, it needs to append 'W2PC' to array_push($receipts[$inny],$nodeValue); // I got this to work array_push($receipts[$inny],$nodeValue .' W2PC'); It just does not stop after the ending total preg_match Below is the function and I would like to know where and how I should structure my loop to only function during the above preg_matchs every element is a cell: this is done with the following in a parent function: $dom = new DOMDocument(); @$dom->loadHTML($html); $xpath = new DOMXPath($dom); $tables = $dom->getElementsByTagName("table"); -------------------------------------------------------------------------- THE TABLE LOOKS LIKE THIS -------------------------------------------------------------------------- DATE CODE DESCRIPTION AMOUNT TERM CREDNO/CLM CHECK NO -------------------------------------------------------------------------------------- W2PC Nov 20, 2009 ATF CONSULT'S FEE $439.55 T99 008640/0000 5649174 Jan 22, 2010 ATF CONSULT'S FEE $424.54 T99 008640/0000 5658412 Feb 26, 2010 ATF CONSULT'S FEE $212.36 T99 008640/0000 5663300 Mar 26, 2010 ATF CONSULT'S FEE $636.80 T99 008640/0000 5668325 May 28, 2010 ATF CONSULT'S FEE $849.07 T99 008640/0000 5677844 Jun 25, 2010 ATF CONSULT'S FEE $17.68 T99 008640/0000 5682804 TOTAL FOR W2PC $2,580.00 --------------------------------------------------------------------------------------- SECOND PAYEE Nov 20, 2009 NOTF NOTICE FEES $15.66 T99 700000/0000 5649993 TOTAL FOR SECOND PAYEE $15.66 --------------------------------------------------------------------------------------- Right now the code grabs the atf fees and the notf from the second payee ---------------------------THE FUNCTION----------------------------------------------- function getPayments($tables,$tableId){ $receipts = array(); $outty = 1; $inny = 0; foreach($tables->item($tableId)->childNodes as $rowId=>$row) { if($row->childNodes){ foreach($row->childNodes as $idx=>$cell) { if($cell->nodeType==XML_ELEMENT_NODE && !preg_match('/^Â/',trim($cell->nodeValue)) && trim($cell->nodeValue) != '') { $nodeValue = preg_replace('/Â/','',trim($cell->nodeValue)); //echo "TableID: $tableId RowId: $rowId CellId: $idx<br>" .$nodeValue. "<br><br><br>"; if(!isset($receipts[$inny])){ //** check first word, should only be 3 chars long **// list($fword) = preg_split('/(\s+| )/',$nodeValue); if(strlen($fword) != 3){ continue; }else{ $receipts[$inny] = array($nodeValue); } }else{ array_push($receipts[$inny],$nodeValue); } //* if it is divisible by 5 then we need to incrment our array pointer *// if(($outty % 5) == 0) $inny++; $outty++; } } } } return $receipts; }
  9. Why is strftime() not working in part of my code? In my page i have #### just for testing that strftime works like it should ##### /// i comment the next 2 lines out when i run the page as this is just debugging $date ='Nov 02, 2009'; echo strftime("%Y-%m-%d",strtotime($date)); //returns '2009-11-02' // this worked as expected ######################################… But further down where I am running the function after getting data via cURL the same thing fails. //$receipt[0] - returned 'Nov 02 , 2009' (See master $receipt array below)had extra white spaces so i did the next str_replace below to make it return 'Nov 02, 2009' - this works $date = trim(str_replace(' ', '', $receipt[0])); //date is not 'Nov 02,2009' $date = strftime("%Y-%m-%d",strtotime($date)); foreach ($receipts as $receipt){ $date = trim(str_replace(' ', '', $receipt[0])); // fixed extra whitespaces now returns 'Nov 02, 2009' echo $date; returns 'Nov 02, 2009' $date = strftime("%Y-%m-%d",strtotime($date)); echo $date; // returns '1969-12-31' // This is not expected results $codeDesc = mysql_real_escape_string($receipt[1]); $amount = mysql_real_escape_string($receipt[3]); } ###############################Info to help debug###################################… PHP Version 5.3.1 Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1 date: date/time support enabled "Olson" Timezone Database Version 2009.18 Timezone Database internal Default timezone America/Chicago Notice the dates in the array with extra spacing --------------------------------------… Just for Ref------------------------------------- Array ( [0] => Array ( [0] => Nov 02 , 2009 [1] => MONEY ORDER/PAYMENT [2] => 17480965680 [3] => $500.00 [4] => 000000 ) [1] => Array ( [0] => Dec 14 , 2009 [1] => MONEY ORDER/PAYMENT [2] => 17483211617 [3] => $231.48 [4] => 000000 ) [2] => Array ( [0] => Dec 14 , 2009 [1] => MONEY ORDER/PAYMENT [2] => 17483211628 [3] => $231.48 [4] => 000000 ) [3] => Array ( [0] => Jan 25 , 2010 [1] => MONEY ORDER/PAYMENT [2] => 9478704011 [3] => $231.58 [4] => 000000 ) [4] => Array ( [0] => Feb 19 , 2010 [1] => EMPLOYER CHECK/ONE D [2] => 6648 [3] => $231.48 [4] => 000000 ) [5] => Array ( [0] => Mar 12 , 2010 [1] => DEBTOR PAYMENT REMIT [2] => 7512 [3] => $231.48 [4] => 000000 ) [6] => Array ( [0] => Mar 12 , 2010 [1] => DEBTOR PAYMENT REMIT [2] => 7513 [3] => $231.48 [4] => 000000 ) [7] => Array ( [0] => Apr 15 , 2010 [1] => EMPLOYER CHECK/ONE D [2] => 7595 [3] => $231.48 [4] => 000000 ) [8] => Array ( [0] => Apr 15 , 2010 [1] => EMPLOYER CHECK/ONE D [2] => 7596 [3] => $231.48 [4] => 000000 ) [9] => Array ( [0] => May 03 , 2010 [1] => DEBTOR PAYMENT REMIT [2] => 7678 [3] => $231.48 [4] => 000000 ) [10] => Array ( [0] => May 03 , 2010 [1] => DEBTOR PAYMENT REMIT [2] => 7679 [3] => $231.48 [4] => 000000 ) [11] => Array ( [0] => Jun 01 , 2010 [1] => DEBTOR PAYMENT REMIT [2] => 7755 [3] => $231.48 [4] => 000000 ) [12] => Array ( [0] => Jun 01 , 2010 [1] => DEBTOR PAYMENT REMIT [2] => 7757 [3] => $231.48 [4] => 000000 ) [13] => Array ( [0] => Jul 19 , 2010 [1] => EMPLOYER CHECK/ONE D [2] => 7838 [3] => $231.48 [4] => 000000 ) [14] => Array ( [0] => Jul 19 , 2010 [1] => EMPLOYER CHECK/ONE D [2] => 7877 [3] => $231.48 [4] => 000000 ) [15] => Array ( [0] => Sep 20 , 2010 [1] => EMPLOYER CHECK/ONE D [2] => 8058 [3] => $231.48 [4] => 000000 ) [16] => Array ( [0] => Sep 20 , 2010 [1] => EMPLOYER CHECK/ONE D [2] => 8059 [3] => $231.48 [4] => 000000 ) [17] => Array ( [0] => Sep 20 , 2010 [1] => EMPLOYER CHECK/ONE D [2] => 8060 [3] => $231.48 [4] => 000000 ) ) --------------------------------------
×
×
  • 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.