tomdchi Posted June 27, 2009 Share Posted June 27, 2009 am having some smarty trouble with data display in a table. I have two arrays values that are related and I am trying to display them in a certain order in a table. The purpose is to reconcile payments to deposits. The table would look like: Date Name Funding ID Status Amount 06/22/09 Tom 6230860059999-13246785 Funded 428.00 06/22/09 Mike 6230860059999-13246785 Funded 225.77 06/22/09 Tom 6230860059999-13246785 Funded 107.00 Total: 760.77 Deposit Date Trans ID Amount Deposited 06/24/09 6230860059999-13246785 760.77 Date Name Funding ID Status Amount 06/25/09 Steve 770875636-13246785 Funded 375.00 06/25/09 Sam 770875636-13246785 Funded 81.15 Total: 456.15 Deposit Date Trans ID Amount Deposited 06/26/09 770875636-13246785 456.15 So there could be multiple sections like above detailing the payments and deposits so they can be reconciled. Each section can have multiple payments but only one deposit. The first array contains data for the payments and the second array has the deposits. I tried using two foreach's but that doesn't display as it is above. I thought maybe I should use section but I am very confused on its syntax for these purposes. I am assigning each array like $query1= blah blah query here $payment_list[] = $rs; $smarty->assign('pmt', $payment_list); $query2= blah blah query here $deposit_list[] = $r2; $smarty->assign('deposit', $deposit_list); Payments and Deposits are tied together with fundingid/transid. Can someone help me out on this? Thanks! Tom Quote Link to comment https://forums.phpfreaks.com/topic/163928-help-with-smarty-foreach/ Share on other sites More sharing options...
phpFirstJoy Posted June 30, 2009 Share Posted June 30, 2009 Is it safe for me to assume that both arrays are sorted by date/time order? If so, you could probably "cheat" a little by taking the first payment and checking it against the first deposit. Are they equal? If not, add the second payment to the first payment. Is the new total equal to the first deposit? If yes, increment to the second deposit and so on. It's not very elegant but it might get the job done! Quote Link to comment https://forums.phpfreaks.com/topic/163928-help-with-smarty-foreach/#findComment-866225 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.