redarrow Posted August 25, 2006 Share Posted August 25, 2006 Thank you.Please can you help $months_payed_for 11 and 12 not working any advice please cheers.all the other conditions with date work but 11 and 12 any idears cheers.[code]<?phpif($months_payed_for=="1"){$d=date("d")+7;$exspire_date=date("$d-m-y");$exspire_date=strtotime($exspire_date);$price="£5";}elseif($months_payed_for=="2"){$d=date("d")+14;$exspire_date=date("$d-m-y");$exspire_date=strtotime($exspire_date);$price="£10";}elseif($months_payed_for=="3"){$d=date("d")+21;$exspire_date=date("$d-m-y");$exspire_date=strtotime($exspire_date);$price="£15";}elseif($months_payed_for=="4"){$d=date("d")+28;$exspire_date=date("$d-m-y");$exspire_date=strtotime($exspire_date);$price="£20";}elseif($months_payed_for=="5"){$d=date("d")+35;$exspire_date=date("$d-m-y");$exspire_date=strtotime($exspire_date);$price="£25";}elseif($months_payed_for=="6"){$d=date("d")+42;$exspire_date=date("$d-m-y");$exspire_date=strtotime($exspire_date);$price="£30";}elseif($months_payed_for=="7"){$d=date("d")+49;$exspire_date=date("$d-m-y");$exspire_date=strtotime($exspire_date);$price="£35";}elseif($months_payed_for=="8"){$d=date("d")+56;$exspire_date=date("$d-m-y");$exspire_date=strtotime($exspire_date);$price="£40";}elseif($months_payed_for=="9"){$d=date("d")+63;$exspire_date=date("$d-m-y");$exspire_date=strtotime($exspire_date);$price="£45";}elseif($months_payed_for=="10"){$d=date("d")+70;$exspire_date=date("$d-m-y");$exspire_date=strtotime($exspire_date);$price="£55";}elseif($months_payed_for=="11"){$d=date("d")+77;$exspire_date=date("$d-m-y");$exspire_date=strtotime($exspire_date);$price="£60";}elseif($months_payed_for=="12"){$d=date("d")+94;$exspire_date=date("$d-m-y");$exspire_date=strtotime($exspire_date);$price="£65";}?>[/code] Quote Link to comment Share on other sites More sharing options...
Orio Posted August 25, 2006 Share Posted August 25, 2006 I dont know why it doesnt work, but why dont you make your script nicer and shorter?[code]<?php$d=date("d")+(7*$months_payed_for);$exspire_date=strtotime(date("$d-m-y"));$price="£".(5*$months_payed_for);?>[/code]Orio. Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 25, 2006 Author Share Posted August 25, 2006 i woluld like to but every condition is diffrent how can i do this with mkdate please helpi tried a unix timestamp no luck yet. Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 25, 2006 Author Share Posted August 25, 2006 This is solved the only way i could come up with was using the time() stamp thanks to the grate php.net cheers all.solved[code]<?phpif($months_payed_for=="1"){$now=time();$exspire_date = mktime(0, 0, 0, date("m", $now) , date("d", $now)+7, date("Y", $now));$price="£5";}elseif($months_payed_for=="2"){$now=time();$exspire_date = mktime(0, 0, 0, date("m", $now) , date("d", $now)+14, date("Y", $now));$price="£10";}elseif($months_payed_for=="3"){$now=time();$exspire_date = mktime(0, 0, 0, date("m", $now) , date("d", $now)+21, date("Y", $now));$price="£15";}elseif($months_payed_for=="4"){$now=time();$exspire_date = mktime(0, 0, 0, date("m", $now) , date("d", $now)+28, date("Y", $now));$price="£20";}elseif($months_payed_for=="5"){$now=time();$exspire_date = mktime(0, 0, 0, date("m", $now) , date("d", $now)+35, date("Y", $now));$price="£25";}elseif($months_payed_for=="6"){$now=time();$exspire_date = mktime(0, 0, 0, date("m", $now) , date("d", $now)+42, date("Y", $now));$price="£30";}elseif($months_payed_for=="7"){$now=time();$exspire_date = mktime(0, 0, 0, date("m", $now) , date("d", $now)+49, date("Y", $now));$price="£35";}elseif($months_payed_for=="8"){$now=time();$exspire_date = mktime(0, 0, 0, date("m", $now) , date("d", $now)+56, date("Y", $now));$price="£40";}elseif($months_payed_for=="9"){$now=time();$exspire_date = mktime(0, 0, 0, date("m", $now) , date("d", $now)+63, date("Y", $now));$price="£45";}elseif($months_payed_for=="10"){$now=time();$exspire_date = mktime(0, 0, 0, date("m", $now) , date("d", $now)+70, date("Y", $now));$price="£55";}elseif($months_payed_for=="11"){$now=time();$exspire_date = mktime(0, 0, 0, date("m", $now) , date("d", $now)+77, date("Y", $now));$price="£60";}elseif($months_payed_for=="12"){$now=time();$exspire_date = mktime(0, 0, 0, date("m", $now) , date("d", $now)+94, date("Y", $now));$price="£65";}[/code] Quote Link to comment Share on other sites More sharing options...
Barand Posted August 25, 2006 Share Posted August 25, 2006 Well, your definition of working must be different to mineTake your "$months_paid_for = 1" case[code]$d = date('d')+7;$exspire_date=date("$d-m-y");echo $exspire_date; // ---> 32-08-06 !!![/code]I suggest you RTFM re date() format stringsAlso if they pay for x months, why is the expiry date calculated by adding 7 * x days. There are 7 days in a week, not a month ???As Orio pointed out, the price is the number of months * 5, until 10 months and above when an extra fiver gets added.This might be closer[code]<?phpecho '<pre>';for ($months_payed_for=1; $months_payed_for<=12; $months_payed_for++) { $expire_date = date ('d-m-Y', strtotime("+$months_payed_for months")); $price = "£".(5*$months_payed_for); printf ('%2d %12s %5s<br>', $months_payed_for, $expire_date, $price);}echo '<pre>';?>[/code] Quote Link to comment Share on other sites More sharing options...
Barand Posted August 25, 2006 Share Posted August 25, 2006 [quote]$now=time();$exspire_date = mktime(0, 0, 0, date("m", $now) , date("d", $now)+77, date("Y", $now));$price="£60";}elseif($months_payed_for=="12"){$now=time();$exspire_date = mktime(0, 0, 0, date("m", $now) , date("d", $now)+94, date("Y", $now));$price="£65";[/quote]With your mathematical ability I really would recommend using PHP to calculate 12 * 7 and not hard-code the values. ;) (Or is the extra 10 days a deliberate bonus?)If you just want to use the current time() values, date('m'), date('d') and date('Y') will suffice. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.