I am creating a site that sells products out of my wifes catalogs. I am trying to make it where she can add a "sale" item. or place any item on sale.
I created the admin form to have it where she can login, and change the descriptions, prices, names, and all that.
I also added a popup_menu using CGI.pm, that is a "onsale" variable, with the options being 0 and 1. 0 being off and default. I have another popup_menu called saleend, which gives 1 to 6 days, 1 week through 3 weeks and always.
So it looks like this:
popup_menu(-name=>"saleend",
-values=> ["","1","2","3","4","5","6","7","14","21","always"],
-labels=>{ "" => "Select One", "1" => "1 Day", "2" => "2 Days", "3" =>
+ "3 Days", "4" => "4 Days", "5" => "5 Days", "6" => "6 Days", "7" =>
+"1 Week", "14" => "2 Weeks", "21" => "3 Weeks", "always" => "Everyday
+" },
-default=>"",
-class=>"select_menu");
My question is this...
Can I do this:
my $saleend = localtime() + ($in{saleend} * 24 * 60 * 60) unless $in{s
+aleend} eq "always";
my $saleend = localtime() + (365 * 24 * 60 * 60) if $in{saleend} eq "a
+lways";
What I'm trying to do, is ADD that much time, in seconds, to the current date. Then I'm inserting that into the database. That way I can have it automatically turn the sales OFF, after they reach the amount of days she gives them.
I have also tried it like this:
my $saleend = time + ($in{saleend} * 24 * 60 * 60) unless $in{saleend}
+ eq "always";
my $saleend = time + (365 * 24 * 60 * 60) if $in{saleend} eq "always";
Is there a easier way to do this?
thx,
Richard
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.