I have a calendar/scheduling script that says (or should say) if today's date is greater than or equal to the 5th day of a certain month, but less than or equal to the 4th or the next month, then use a specific page, if not, then go to the next one..... So I have this for example:
$month = date("Y-m-j"); echo $month; if ($month >= "2010-03-5" && $month <= "2010-04-4") { include('may.php'); } else if ($month >= "2010-04-5" && $month <= "2010-05-4") { include('june.php'); } else
4/12/2010 11:06:39 PM
show us your face or tits first
4/12/2010 11:09:20 PM
i'm not a php programmer, but should that "j" be a "d" in the first line...?
4/12/2010 11:11:36 PM
^^ ^ 'j' means the day without the leading zeros......I've got it set so it's the YEAR - (4 digit), MONTH - (leading zero included) - DAY (no leading zeros) so today's date 2010-04-12
4/12/2010 11:16:55 PM
consider using this kind of approach instead
<?php $monthpages = array(); $monthpages[] = 'january.php'; $monthpages[] = 'february.php'; $monthpages[] = 'march.php'; $monthpages[] = 'april.php'; $monthpages[] = 'may.php'; $month = date("Y-m-j"); // get today's date $t = strtotime($month); // get the numeric representation of today's date $t = $t - 5*60*60*24; // subtract five days from today's date $monthindex = date("n", $t); // get the month of 5 days ago echo $monthpages[$monthindex - 1]; // oh look, the month corresponds to the index in the array?>
4/12/2010 11:34:07 PM
if ("2010-04-12" >= "2010-03-5" && "2010-04-12" <= "2010-04-4")[Edited on April 12, 2010 at 11:53 PM. Reason : looks like true && true to me]
4/12/2010 11:53:10 PM
Yeah I was wondering why you weren't using an array here.
4/12/2010 11:53:20 PM
yes qt! well sorta....that makes sense why it wouldn't work (date comparison not string comparison) But.....it looks like the formula is a set formula (i.e. subtracting days in relation to the current date) but that won't work because if someone comes to the page on April 5 OR May 4, they'd get june.php....so it's not just a matter of adding days, hence the 'between' certain dates thing....?^and I was told an array was the better way to go but didn't know how to write it [Edited on April 13, 2010 at 12:01 AM. Reason : k ]
4/13/2010 12:00:34 AM
well if it's a formula, you can program it
4/13/2010 12:01:53 AM
Use date('Ymd'), then your >= and <= will actually work properly.Then you can just do:if (($month >= 20100305) && ($month <= 20100404))With qntmfred's code sample, you can use functions like mkdate() to simplify adding and subtracting dates.
4/13/2010 12:02:11 AM
thx you all I barely know php/mysql as it is so I doubt I could write a formula....and I know an array would be better, but for the time being, I've done what Stein has suggested and it's working great Thanks you guys
4/13/2010 12:26:40 AM
well shit, i got here too late.
4/13/2010 12:58:54 AM
I mean shit, I got plenty of questions that come up if you get bored....this can be my thread for my stupid code questions [Edited on April 13, 2010 at 1:35 AM. Reason : ]
4/13/2010 1:34:14 AM
4/13/2010 6:13:50 AM
Read a damn book or something alreadyI mean damn
4/13/2010 8:36:30 AM
4/13/2010 10:04:38 AM
ya you should totally be using ruby on rails
4/13/2010 10:06:45 AM
ruby on rails manages to be worse than php, which is a pretty amazing accomplishment.
4/13/2010 10:12:24 AM
Shaggy refuses to write any sort of code or script in anything other than binary.
4/13/2010 10:58:13 AM
java or c# are the only languages worth knowing these days.
4/13/2010 1:48:06 PM
also, I'd like to add that IE is the only real browser. If it works in IE that is enough.
4/13/2010 2:23:22 PM
^ yep. Better get ready for IE9 tho. If it doesnt work in IE then it doesnt work.
4/13/2010 2:26:57 PM
I don't know about IE9. Sounds like MS is moving into some sort of standard that others follow and that is not an IE tradition. I'm going to stick with IE6 for now since that is more or less the last browser to get it right.
4/13/2010 2:28:34 PM
IE9 is going to be good cause its only going to implement the features of html5 that are worthwhile. Which owns. Silverlight owns too.
4/13/2010 2:32:39 PM
You should start a blog so we can keep up with trends. I've wasted so much time supporting inferior browsers to IE because I thought I had to, you could have saved me a lot of time and pain.
4/13/2010 2:34:05 PM
im just trying to help out where i can. If you write anything having to do with html/css/js by hand you're really pretty bad, and unless you're an irl designer w/ like a design degree and a bunch of other stuff you probably did it wrong. protip: Use java/c# for the backend and ui component code, and then have your designers skin it. oh yea, also unless you're doing something that doesnt matter at all, sql server for the database server.mysql, lol, what a joek.
4/13/2010 2:37:41 PM
Thanks, much appreciated!
4/13/2010 2:41:06 PM
I think I got dumber reading the last 8 posts in here.
4/13/2010 10:04:54 PM
we all got dumber Talage. we all got dumber.
4/13/2010 10:08:56 PM
soooooooo...........IE, java, and C = awesomephp, mysql, firefox = the worst shit evahright?
4/13/2010 10:14:42 PM
^you got it! Glad to see shaggy is helping more users than just me!
4/13/2010 10:17:26 PM
extremely obvious trolling ITT
4/14/2010 8:38:24 AM
not even trolling. all languages that start with p are shit and mysql is awful.html/js/css are the languages of idiots, and if you find yourself spending alot of time there (and you aren't a framework developer) you should probably rethink your life. Maybe read up on some modern c# MVC stuff, or if you still want to hate yourself a little try richfaces.html is a total joke and html5 isn't worth learning, especially when you dont know what parts IE9 is gonna support. tbqh http is really only useful as a transport for SOAP, and you should be writing your clients in silverlight.
4/14/2010 9:28:32 AM
I sometimes wonder if shaggy is employed and who employed him. Knowledge like that should not go unnoticed.[Edited on April 14, 2010 at 9:33 AM. Reason : .]
4/14/2010 9:32:33 AM
4/14/2010 9:39:07 AM
the best trolls never admit to trolling
4/14/2010 7:11:26 PM