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 6 of 6
  1. #1
    New Coder
    Join Date
    Oct 2009
    Location
    Dallas,Tx USA
    Posts
    54
    Thanks
    4
    Thanked 0 Times in 0 Posts

    generate 5 dates

    how to generate 5 dates in a drop down list .
    based on noofdays value that many dates should be generated. I am using this but it is giving 01/01/1970.

    plz help

    PHP Code:
    Reservation Date :&nbsp;</td>
                            <td align="left"><select name="ResrvDate" type="text" class="textbox" id="ResrvDate" value="">
                            <?$Count 0;

            while(
    $Count $NoOfDays){
                                            
    $datesdate("m/d/Y",strtotime(date("m/d/Y"strtotime($date)) . " + " $Count " day")) . "<br />";
                                                    
    ?>
                                            <option value = "<?echo $dates?> "> <? echo $dates ?> </option>
                                        <? $Count++;}?>

  • #2
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    What is the value of $date? Do an echo before that line to see. Also What is with the strtotime(date(strtotime(date))) stuff? You shouldn't need all that
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)

  • #3
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,493
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Describe the starting date, and what the other 5 dates would look like.

  • #4
    New Coder
    Join Date
    Oct 2009
    Location
    Dallas,Tx USA
    Posts
    54
    Thanks
    4
    Thanked 0 Times in 0 Posts
    I am new to this stuff. I got this code from google.

    coming to the start date will be current day's date. in mm/dd/yyyy format.
    $todaysdate = date("m/d/Y");


    so every day when some one views the page the dates should be 5 days dates from that date.
    Last edited by gadaschowdary; 01-13-2010 at 10:07 PM.

  • #5
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    PHP Code:
    <?php

    echo "<select>";

    $counter 1;

    while (
    $counter <= ) {
    $date date('Y-m-d'strtotime(" + $counter day"));
    echo 
    "<option value=\" $date\"> $date </option>\n";
    $counter++;
    }

    echo 
    "</select>";

    ?>
    Last edited by Len Whistler; 01-13-2010 at 10:45 PM.
    Leonard Whistler

  • #6
    New Coder
    Join Date
    Oct 2009
    Location
    Dallas,Tx USA
    Posts
    54
    Thanks
    4
    Thanked 0 Times in 0 Posts
    thanx!! it worked


  •  

    Posting Permissions

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