Jump to content

486974

Members
  • Posts

    34
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

486974's Achievements

Member

Member (2/5)

0

Reputation

  1. Thank you very much for the help Ken works a treat
  2. Sorry wrong code above when i said it didnt work it does when you type in January 01 and 5 days returns 500 but if you type in January 02 and 5 days it returns 400 and that should be 500 <?php echo $_POST['sdate']; ?> <font size="3"> X </font> <?php echo $_POST['days']; ?> <font size="3"> Days = </font> <?php $array = array( 'January 01' => 100, 'January 02' => 100, 'January 03' => 100, 'January 04' => 100, 'January 05' => 100, 'January 06' => 100, 'January 07' => 100, 'January 08' => 100, 'January 09' => 100, 'January 10' => 100, 'January 11' => 100, 'January 12' => 100, 'January 13' => 100, 'January 14' => 100, 'January 15' => 100, 'January 16' => 100, 'January 17' => 100, 'January 18' => 100, 'January 19' => 100, 'January 20' => 100, 'January 21' => 100, 'January 22' => 100, 'January 23' => 100, 'January 24' => 100, 'January 25' => 100, 'January 26' => 100, 'January 27' => 100, 'January 28' => 100, 'January 29' => 100, 'January 30' => 100, 'January 31' => 100, ); $date = $_POST['sdate']; $days = $_POST['days']; $h_days = $days; $total_price = 0; foreach ($array as $key => $price) { if ($key === $date || $days < $h_days) $total_price += $price; if (--$days === 0) break; } echo $total_price; ?>
  3. <form action="welcome.php" method="post"> Start Date: <input type="text" name="sdate" /> Days: <input type="text" name="days" /> <input type="submit" /> </form> <br><br> <?php echo $_POST['sdate']; ?> <font> X </font> <?php echo $_POST['days']; ?> <font> Days = </font> <?php $array = array( 'January 01' => 100, 'January 02' => 100, 'January 03' => 100, 'January 04' => 100, 'January 05' => 100, 'January 06' => 100, 'January 07' => 100, 'January 08' => 100, 'January 09' => 100, 'January 10' => 100, 'January 11' => 100, 'January 12' => 100, 'January 13' => 100, 'January 14' => 100, 'January 15' => 100, ); $date = 'January 01'; $days = 3; $h_days = $days; $total_price = 0; foreach ($array as $key => $price) { if ($key === $date || $days < $h_days) $total_price += $price; if (--$days === 0) break; } echo $total_price; ?>
  4. thanks for your help ken2k7 still cant get it to work obviously no common sense
  5. Sorry didnt explain that too well. If i add more days to the code as not everyone wants 3 days it doesnt work <?php $date = 'January 02'; $days = 3; $days = 4; $days = 5; //Dont know if im putting days in right place $h_days = $days; $total_price = 0; foreach ($array as $key => $price) { if ($key === $date || $days < $h_days) $total_price += $price; if (--$days === 0) break; } echo $total_price; http://www.disneysvacationvillarentals.net/3_Bedroom/BL1099/welcome.php
  6. Whatever i change days figure too thats what it changes the price to on my webpage if i type the days the code does not work out the price <?php $date = 'January 02'; $days = 3;
  7. Each day has a value assigned and if i type in January 01 into the date box it returns the figure 100 ideally what i want the script to do if i type in 3 in the days box i want it to add January 01 to January 02 and then January 03 and produce the answer 310. 'January 01' => 100, 'January 02' => 120, 'January 03' => 90, 'January 04' => 100, 'January 05' => 120,
  8. Hello All I have a simple form which has start date and days the idea is someone inputs there start date and how many days they are staying and it works out the price can someone tell me how i get what someone types into the box which then gets the figure which corresponds to that date then if someone types in 5 days then the script adds the next 5 figures together. I have added a piece of code which i copied from a tutorial and have tried changing it so it just multiplies the start date figure by how many days are inputted i couldn't get the code to get the date value whatever i tried. <form action="welcome.php" method="post"> Start Date: <input type="text" name="sdate" /> Days: <input type="text" name="days" /> <input type="submit" /> </form> <br><br> <?php echo $_POST['sdate']; ?> <?php echo $_POST['days']; ?> <?php $array = array( 'January 01' => 100, 'January 02' => 120, 'January 03' => 90, 'January 04' => 100, 'January 05' => 120, ); echo $array[$_POST['sdate']]; ?> <?php function mySum($numX, $numY){ $total = $numX * $numY; return $total; } $myNumber = 0; echo "Before the function, myNumber = ". $myNumber ."<br />"; $myNumber = mySum($array[$_POST['sdate']];,$_POST['days']; // Store the result of mySum in $myNumber echo "After the function, myNumber = " . $myNumber ."<br />"; ?>
  9. Thanks Ken2k7 that worked how i want it too, but i cant find a tutorial to help write the script i need for adding the totals depending on how many days are entered would i use the IF statement if 3 is entered then how would i add each array total together.
  10. 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
  11. <?php $txt="January 01"; $x=100; $txt="January 02"; $x=120; $txt="January 03"; $x=90; ?> then i used an if statement and nothing worked i am new to this and trying to teach myself with the online tutorials but its just mind boggling
  12. 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
  13. Hi all, I am trying to add this script to a calendar availability button so if the user is in the UK it redirects to the UK pound calendar and if you are in the USA/Canada it goes to the USA dollar calendar and anywhere else in the world goes to the default calendar which is the UK pound one i have tried with header but can only get one url to work. The section of code i have highlighted in bold is where we think the problem is Please help <?php if (getenv(HTTP_X_FORWARDED_FOR)=="") { $ip = getenv(REMOTE_ADDR); } else { $ip = getenv(HTTP_X_FORWARDED_FOR); } $numbers=explode (".",$ip); $code=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]); $lis="0"; $user = file("http://www.disneysvacationvillarentals.net/data.dat"); [b]for($x=0;$x<sizeof($user);$x++) { $temp = explode(";",$user[$x]); $opp[$x] = "$temp[0];$temp[1];$temp[2];$temp[3];$temp[4];"; if($code >= $temp[0] && $code <= $temp[1]) { $list[$lis] = $opp[$x]; $lis++; } {[/b] } if(sizeof($list) != "0") { for ($i=0; $i<sizeof($list); $i++){ $p=explode(';', $list[$i]); switch ( $p[4] ) { case 'UNITED KINGDOM' : ("http://www.rentalsystems.com/advert_price.asp?ref=51648&rag=47967B&rcam=ownerweb/"); break; case 'United States' : ("http://www.rentalsystems.com/advert_price.asp?ref=51646&rag=47967B&rcam=ownerweb/"); break; case 'Canada' : ("http://www.rentalsystems.com/advert_price.asp?ref=51646&rag=47967B&rcam=ownerweb/"); break; default : ("http://www.rentalsystems.com/advert_price.asp?ref=51648&rag=47967B&rcam=ownerweb/"); break; } } }else{echo "Unable to determine your country"; } ?>
  14. Hi thanks for your reply would i have put that line for each country and where i want to direct it too
  15. hi all, i am using an Ip-to-country script which echos what country the user is from is there anyway once it comes up with the country of redirecting from that page to another e.g lets say user is from UK then they get redirected to a UK booking calendar if they are from the US they redirected to a US booking calendar heres the script <?php if (getenv(HTTP_X_FORWARDED_FOR)=="") { $ip = getenv(REMOTE_ADDR); } else { $ip = getenv(HTTP_X_FORWARDED_FOR); } $numbers=explode (".",$ip); $code=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]); $lis="0"; $user = file("data.dat"); for($x=0;$x<sizeof($user);$x++) { $temp = explode(";",$user[$x]); $opp[$x] = "$temp[0];$temp[1];$temp[2];$temp[3];$temp[4];"; if($code >= $temp[0] && $code <= $temp[1]) { $list[$lis] = $opp[$x]; $lis++; } } if(sizeof($list) != "0") { for ($i=0; $i<sizeof($list); $i++){ $p=explode(';', $list[$i]); echo "You are from $p[4]"; } }else{echo "Unable to determine your country"; } ?> in the package is a DAT file aswell
×
×
  • 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.