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

    Unhappy Dynamically Created Due Dates from ONE db file

    Okay, so, what I'm trying to do is automatically create a recurring due date calendar based on the original due date that is stored in a database file. Here's what I have so far:

    Code:
    require ('connect.php');
    $myusername = $_SESSION["myusername"];
    $data = mysql_query("SELECT * FROM clients WHERE client_id = '{$_SESSION["client_id"]}'") or die(mysql_error());
    $row = mysql_fetch_assoc($data);
    
    // Generates due dates
    $startdate = $row['datestart'];
    $date = new DateTime($startdate);
    $interval = new DateInterval('P1M');
    That sets everything up, then I have a while {} loop that will output to a dynamic table where it will need to
    Code:
     echo $date
    right before the end of the while{} I have
    Code:
    $date->add($interval);
    Now that I have all syntax errors worked out...it's not displaying anything but my table headers and then nothing...at all.

    Any suggestions???

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

    Exclamation Another code possiblity...problem output

    Okay, so the above code doesn't work in a while loop...not sure why, however this code does...except it starts WAY before I $startdate
    PHP Code:
    $time strtotime("2010-12-11");
    $final date('m.d.Y'strtotime("+1 month"$time));
    echo 
    date('m.d.Y'$time) . "<br />";
    echo 
    $final ."<br />";
    while (
    $final <= $_SERVER['REQUEST_TIME']) {
        
    $final strtotime("+1 month"$final);
        echo 
    date('m.d.Y'$final) . "<br />";

    And the output STARTS correctly, then resets the $final date and then counts up...any suggestion as to WHY that is?

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

    Thumbs up Fixed!!!

    Okay...so thanks for nothing...here's the code that works!!!

    PHP Code:
    $startdate strtotime('2010-01-01');
    $today strtotime('now');
    echo 
    $startdate " = "date('m.d.Y'$startdate);
    echo 
    "<br />";
    while (
    $startdate <= $today) {
        echo 
    "<br />";    
        
    $startdate strtotime('+1 month'$startdate);
        echo 
    date('m.d.Y'$startdate);
        echo 
    "<br />";

    Not sure exactly what happened...but it works, that's all I give a damn about!


  •  

    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
    •