Page 1 of 1
Previous Dates
Posted: Mon Dec 18, 2006 12:02 am
by iknownothing
Hello all,
OK I'm building an administration page on one of my site. It pulls all items from a particular table in the database, and highlights items which are deadlined for the current date, but i would also like to highlight ALL previous dates indicating that it is overdue.
the closest way that i can think of (although not right), would be:
Code: Select all
if ($day == date("d")--){
...do highlight thing...
}
else {
...do nothing...
}
thanks.
Re: Previous Dates
Posted: Mon Dec 18, 2006 3:15 am
by timvw
iknownothing wrote:It pulls all items from a particular table in the database, and highlights items which are deadlined for the current date, but i would also like to highlight ALL previous dates indicating that it is overdue.
How are the dates stored in your database? (the column type??)
In the most simply case you would use the < (smaller than
comparision operator)
Posted: Mon Dec 18, 2006 8:05 am
by iknownothing
i have set it up so that the day, month and year are in separate columns Integer type), probably not the best way to do it but its the way I did it.
So, I take it I implement the < like so (for example):
Code: Select all
$currentdate = date("dmy");
$completiondated = row ['compd'];
$completiondatem = row ['compm'];
$completiondatey = row ['compy'];
$date = $completiond . $completionm . $completiony;
if ($currentdate > $date) {
...do thing...
}
else {
...do nothing...
}
I would test it out for myself but the original code isnt right in front of me at the moment and figured I'd make sure I'm right before I spend more hours trying to figure out what the hell I'm doing...
Thanks for your help too...
Posted: Mon Dec 18, 2006 1:28 pm
by timvw
iknownothing wrote:i figured I'd make sure I'm right before I spend more hours trying to figure out what the hell I'm
In that situation i would recommend to read a tutorial about php and mysql.. eg: you're comparing a date ($currentdate) against a string ($date)...