If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Please Help With SQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-26-04, 17:42
wusongchina wusongchina is offline
Registered User
 
Join Date: Mar 2004
Posts: 5
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!
Reply With Quote
  #2 (permalink)  
Old 03-26-04, 18:58
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
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
Reply With Quote
  #3 (permalink)  
Old 03-27-04, 09:18
harikishore harikishore is offline
Registered User
 
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 .
Reply With Quote
  #4 (permalink)  
Old 03-27-04, 11:51
wusongchina wusongchina is offline
Registered User
 
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.
Reply With Quote
  #5 (permalink)  
Old 03-27-04, 12:46
wusongchina wusongchina is offline
Registered User
 
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 12:48.
Reply With Quote
  #6 (permalink)  
Old 03-27-04, 13:12
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
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
Reply With Quote
  #7 (permalink)  
Old 03-27-04, 23:39
wusongchina wusongchina is offline
Registered User
 
Join Date: Mar 2004
Posts: 5
Quote:
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!
Reply With Quote
  #8 (permalink)  
Old 03-28-04, 01:36
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On