Jump to content

Values to dates


486974

Recommended Posts

Hi All,

 

I am trying to give separate dates a value e.g January 01 = 100, January 02 = 120, January 03 = 90  so when someone types lets say January 01 into my form and then 3 into days part of the form the script will add January 01, January 02 and January 03 together and echo 310 i want to do it for a whole year the simple form i am using is

 

<form action="welcome.php" method="post">

Start Date: <input type="text" name="sdate" />

End Date: <input type="text" name="days" />

<input type="submit" />

</form>

 

then on the welcome.php i have

 

<?php echo $_POST['sdate']; ?>

 

X

 

<?php echo $_POST['days']; ?>

 

Days

 

= (TOTAL) UK Sterling

 

which produces the date and days but I'm baffled to how i put values and then add them together

 

can anyone help please

Link to comment
https://forums.phpfreaks.com/topic/159627-values-to-dates/
Share on other sites

How do i call the array after someone else has inputted there date and once they type in the amount of days add the values of the dates together and then print on screen.

 

Dont know if i have explained that right the form is at

 

http://www.disneysvacationvillarentals.net/3_Bedroom/BL1099/welcome.php

 

If you type in January 01 and then 3 you will see what i mean

Link to comment
https://forums.phpfreaks.com/topic/159627-values-to-dates/#findComment-841977
Share on other sites

$_POST['sdate'] holds the value the user entered right? Well, if your array is set up with keys of sdate, then you can use $array[$_POST['sdate']], but you should always check if the $array has such index, otherwise if someone type "January 1", it would result in an error because $array doesn't have an index at "January 1", but at "January 01".

Link to comment
https://forums.phpfreaks.com/topic/159627-values-to-dates/#findComment-841982
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.