tulip Posted April 5, 2008 Share Posted April 5, 2008 Hi, i am a really newbie in PHP stuck on getting the expired_date of warranty. I just add date_purchase using javascript that stored the date in text of dd/mm/yyyy. But i don't know how to find the expired_date according to warrantyNo provided. I try to write the if statement if( $warrantyNo = '100')) { date_purchase=+= 1*24*60; }elseif($warrantyNo = '102') { date_purchase=+= 2*24*60; }elseif($warrantyNo = '102') { date_purchase=+= 4*24*60; } I know i am very wrong but how to make it please? Link to comment https://forums.phpfreaks.com/topic/99645-calculate-warranty-expired/ Share on other sites More sharing options...
benjaminbeazy Posted April 5, 2008 Share Posted April 5, 2008 switch($warranty){ case '100': $date_purchase = 1*24*60; break; case '102': $date_purchase = 2*24*60; break; } follow that format Link to comment https://forums.phpfreaks.com/topic/99645-calculate-warranty-expired/#findComment-509763 Share on other sites More sharing options...
tulip Posted April 8, 2008 Author Share Posted April 8, 2008 thanks for the respond. I will try it on. Link to comment https://forums.phpfreaks.com/topic/99645-calculate-warranty-expired/#findComment-512509 Share on other sites More sharing options...
tulip Posted April 10, 2008 Author Share Posted April 10, 2008 my table of warranty_reg is warrantyNo, datetime, days my codes <?php $calPurchaseDate = time(); //the same as now() switch($WarrantyNo){ case '100': $ calPurchaseDate += 30*24*60*60; //if warranty no is 100 then, adding 30 days in seconds break; case '102': $ calPurchaseDate += 60*24*60*60; //if warranty no is 100 then, adding 60 days in seconds break; } $sql = "UPDATE `warranty_reg` SET `days` = ".$ calPurchaseDate.";"; $result = mysql_query($sql); ?> how to set the 'days' in my table as it still record 30days even WarrantyNo entered 100 or 102?? I don't know how to make it correctly. please help. Link to comment https://forums.phpfreaks.com/topic/99645-calculate-warranty-expired/#findComment-513500 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.