Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Apr 2013
    Posts
    15
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Angry Payment from DB entered into loop

    What I'm doing is dynamically creating a table that automatically calculates the due date (based off of original, single DB entry) and what I need to do NOW is interrupt the loop at a certain point to inject a payment from another table. Here's the code that I have:
    PHP Code:
    while($startdate <= $today)
    {
        if (
    $pmt_date $startdate) {
            echo 
    '<tr><td style="border-bottom-color:#3105b0; border-bottom-style:dashed; border-bottom-width:thin;"><center>'date("m.d.Y"$startdate) . '</center></td>';
            echo 
    '<td style="border-bottom-color:#3105b0; border-bottom-style:dashed; border-bottom-width:thin;"><center>'"$" $english_format_number number_format($row["supportamount"], 2'.',',') . '</center></td>';
            echo 
    '<td style="border-bottom-color:#3105b0; border-bottom-style:dashed; border-bottom-width:thin;"><center>$0.00</center></td>';
        } else {
            echo 
    '<tr><td style="border-bottom-color:#3105b0; border-bottom-style:dashed; border-bottom-width:thin;"><center>'date("m.d.Y"$pmt_date) . '</center></td>';
            echo 
    '<td style="border-bottom-color:#3105b0; border-bottom-style:dashed; border-bottom-width:thin;"><center>$0.00</center></td>';
            echo 
    '<td style="border-bottom-color:#3105b0; border-bottom-style:dashed; border-bottom-width:thin;"><center>'"$".$english_format_number number_format($row2["pmt_amt"], 2'.',',') . '</center></td>';
        } 
    There's NO injection of payment into the generated calendar. Any suggestions or what am I doing wrong???

  • #2
    New Coder
    Join Date
    Apr 2013
    Posts
    15
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Angry

    Okay, so...it DOES work, however it stops when $startdate and $pmt_date are = then stops and echos the same thing continuously.

    Anyway to have it only insert the field then continue to adding one month until the next field is reached?

  • #3
    New Coder
    Join Date
    Apr 2013
    Posts
    15
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Okay guys, since I got no help from this forum, I figured I'll share what I did get to work for this purpose.

    The output is somthing akin to this:

    Date | Amt Due | Amt Paid |...
    01.01.2012| $500.00 | $0.00 |...
    01.15.2012| $0.00 | $500.00 |....
    02.01.2012| $500.00 | $0.00 |....
    etc

    To Get the payment (or anything from another db file) to be inserted follow this:
    PHP Code:
    while($monthStart <= $today)
    {
        
    $payment_found false;
      foreach (
    $payments as $payment)
      {
           
    // Things to be done when payments are FOUND
      
    }
      if (!
    $payment_found)
      {
           
    // Things to be done when payments are NOT FOUND

    After doing this code, I noticed that it didn't put the due date line for the same month that a payment was made...so here is what I did.

    PHP Code:
    while($monthStart <= $today)
    {
        
    $payment_found false;
      foreach (
    $payments as $payment)
      {
           if (
    strtotime($payment['pmt_date']) > $monthStart) {
                 
    // Inserts the date line when payment is made within the same month. 
           
    }
           
    // Things to be done when payments are FOUND
      
    }
      if (!
    $payment_found)
      {
           
    // Things to be done when payments are NOT FOUND

    Hope this helps anyone who wants to do something similar.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •