Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2004
    Posts
    5

    Unanswered: Please Help With SQL

    I have "checkindate" and "checkoutdate", I would like to know a SQL that can do this:

    When "checkindate" is offered a value, say 2004-12-05, the "checkoutdate" automatically change to two days later, that's 2004-12-07

    Can I do that with SQL and PHP?

    Thanks in advance!

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Maybe SQL can do this for you, but it would be better handled in PHP.

    If you'd like one of us to take a shot at doing it via SQL, let us know which SQL Engine (Oracle, DB2, Microsoft, etc) and version you are using. You might also want to review just what you are asking for, since I think you might have the checkin/checkout backwards too.

    -PatP

  3. #3
    Join Date
    Mar 2004
    Location
    chennai
    Posts
    9
    hello
    just now i had ur question. i can't understand ur problem.
    send details to my email. i can solve .

  4. #4
    Join Date
    Mar 2004
    Posts
    5
    Do you happen to know a similar calendar like the Holiday Inn's?

    http://www.ichotelsgroup.com/h/d/hi/1/en/home

    When you select, say March 1, 2004 for the check-in date, the check-out date will be immidately changed to March 2, 2004, without the need to use the calendar again.

    Thanks.

  5. #5
    Join Date
    Mar 2004
    Posts
    5
    They have a set of javascript in the source code file, but I'm not sure if it's this code working behind the screen.

    Please help
    Last edited by wusongchina; 03-27-04 at 13:48.

  6. #6
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    In PHP dates are just integers. You can use:
    PHP Code:
    $today Getdate();
    $tomorrow $today
    So, if the user enters a date for check-in, you can easily compute a default check-out date by adding 1 to the check-in date. This can be done interactively, in the browser instead of requiring a round-trip to the database.

    -PatP

  7. #7
    Join Date
    Mar 2004
    Posts
    5
    Originally posted by Pat Phelan
    In PHP dates are just integers. You can use:
    PHP Code:
    $today Getdate();
    $tomorrow $today
    So, if the user enters a date for check-in, you can easily compute a default check-out date by adding 1 to the check-in date. This can be done interactively, in the browser instead of requiring a round-trip to the database.

    -PatP
    Cheers :-)
    Thank you Pat!

    I'm new to PHP, but I do tried this:
    PHP:--------------------------------------------------------------------------
    // get fields from form
    $x_RecordID = @$HTTP_POST_VARS["x_RecordID"];
    $x_hyperlink = @$HTTP_POST_VARS["x_hyperlink"];
    $x_PublicPrice = @$HTTP_POST_VARS["x_PublicPrice"];
    $x_StarRating = @$HTTP_POST_VARS["x_StarRating"];
    $x_DepartureID = @$HTTP_POST_VARS["x_DepartureID"];
    $x_ArrivalID = @$HTTP_POST_VARS["x_ArrivalID"];
    $x_CheckinDate = @$HTTP_POST_VARS["x_CheckinDate"];
    $x_Cruise = @$HTTP_POST_VARS["x_Cruise"];
    $x_length = @$HTTP_POST_VARS["x_length"];
    $x_CheckoutDate = @$HTTP_POST_VARS["x_CheckoutDate"];
    $x_checkindate = Getdate();
    $x_heckoutdate = 1 + $x_checkindate;

    I added
    $x_checkindate = Getdate();
    $x_heckoutdate = 1 + $x_checkindate;
    PHP:--------------------------------------------------------------------------

    Then it shows, Fatal error: Unsupported operand types

    Please help, thanks!

  8. #8
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Based on what you are trying to do, I don't think that PHP is a good choice. PHP runs on the server, not on the client. What you seem to be trying to do is interactively modify data from your (static) HTML page.

    This can be done using PHP, but not the way you are trying to do it because all of the PHP code executes after the user submits the page. To get the effect you seem to want, you need code to execute on the client, so I'd recommend using JavaScript instead (or VB Script if you only need to support Internet Explorer).

    You can get the same effect using PHP, but you'd have to radically re-think your page design. You'd need to force a round-trip to the server for the calendar pick for CheckInDate. While you were executing on the server, you could post a new value for the CheckOutDate. You'd have to be wary to be sure that you didn't accidentally overwrite a value that the user had entered too, which would be bad.

    You'll need to think about how you want to approach this, but I think your present path isn't going to get you where you want to go.

    -PatP

Posting Permissions

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