Sleeper Posted November 13, 2007 Share Posted November 13, 2007 OK I have ventrued out of html and trying some php. I have a radio station adn I want the managers to be able to log into a are and edit the timesheet and have those changes take effect on the timehsheet page. This part was easy and I have it all coded up. The part im having an issues with is right now at the end of every night on the html timesheet we use i go in and shade out the font colors for the day. This I dont know how to make happen on the php side. so far I have http://www.webcityradio.net/timesheet/inc/index.php and this has a date box and mondays date would be $date1 and $m1fc would be the results of the font color choise on monday box one what I was hopging to do is somthing like if $date1 <= date("m/d/y") color="$m1fc" else color="#000000" but I dont know how to work this into the coding on the final page when it pulls everything together. Right now I have <b><font face="'.$font.'" size="'.$fontsize2.'" color="'.$m1fc.'">'.$m12to3.'</font></b> So how would I change color automaticly for mondays entreys on tuesday 12:01am. I hope I have provided enough info on what im thinking and trying to do. and I look forward to some much needed help...lol Quote Link to comment Share on other sites More sharing options...
bwochinski Posted November 13, 2007 Share Posted November 13, 2007 Do you want these things to change based on the day of the week, or change the color for dates already past, or just change the color of the current date? Or some other condition I didn't mention? Quote Link to comment Share on other sites More sharing options...
Sleeper Posted November 13, 2007 Author Share Posted November 13, 2007 I want the font color to change based one the current day vrs the date entered in the $date1 field. So as in today being Monday $date1 = 11/12/07 so everything would be normal. Then tomorrow all fields in Mondays column would check the current date of 11/13/07 vrs $date1(11/12/07) and see that date is pasted and change the color of the font to the second option. I would then continue this on for each day so that as each day ended it would shade it self out automaticly showing that the day is done with. Making it easyier to read the timesheet. Jim Quote Link to comment Share on other sites More sharing options...
gin Posted November 13, 2007 Share Posted November 13, 2007 First, I'd advise you to use CSS, since <font> is depreciated. It'll make dealing with the colors and other formatting much much easier. Next for comparing dates, change the the date into a timestamp with strtotime(). After that, I'm pretty sure you'll be able to figure things out. Quote Link to comment Share on other sites More sharing options...
Sleeper Posted November 13, 2007 Author Share Posted November 13, 2007 Not realy. Its been about 6 years sence i used css there one of those things that where cool but not ready to be widly exepted kinda like flash so I stoped using it and then it caugh back on while i wasnt watching..lol But other then ussing the css and changing to the timestamp I still have no idea how to do a if $date1 <= date("m/d/y") color="$m1fc" else color="#000000" type set up to make the color change automaticly. How about this. Let see if this can be answer any easier. What if I just want the day that is == to highligh and the rest shade out so it would be like if $date1 == date("m/d/y") color="$m1fc" else color="#000000" all I need to know is how I would code this into the page to make the font change. Quote Link to comment Share on other sites More sharing options...
Sleeper Posted November 13, 2007 Author Share Posted November 13, 2007 And actuly in this case I cant use the css for the font color cause the main color will be dependnt on the persons name in the timesheet. Each person could have there own color if needed. In the form I provided there is a male / female /and auto dj option which would allow for 3 difernt font colors depending on there choise. So not sure how the css would apply to this situation. I wouldnt think that this would be that big of a deal but it not only stumped me and the few php people around me but no one on thos forum knows how to do this either? Quote Link to comment Share on other sites More sharing options...
revraz Posted November 13, 2007 Share Posted November 13, 2007 If you can use Color= in your code, then you can use CSS Quote Link to comment Share on other sites More sharing options...
Sleeper Posted November 13, 2007 Author Share Posted November 13, 2007 well if the color= is all dependant on a drop down selection on a form im not sure how that could be set to a css. And that drop down can change depending on the configuration. That is not the issue at hand though. but thanks for posting about it sence it has nothing to do with the issue. The issue is simply I want to be able to have the color auto change after the day is over on the timesheet to show that the day is over. Quote Link to comment Share on other sites More sharing options...
Sleeper Posted November 13, 2007 Author Share Posted November 13, 2007 OK well thanks for the help on this one guys but I have figured this out on my own. Its a alot of coding sence there are 77 spots that can change font color depending on day or on dj in the timesheet but I did a call to auto.php and on auto.php I did <?php include ("config.php"); include ("data_timesheet.php"); $d=date("m/d/y"); //FC1 if ($d<=$date1) $fc1="$m1fc"; else $fc1="$fontcolor2"; ?> I just had to do this 77 times. Fun for me but it works out perfict. guess good old fashion brain power and not giving up still works better then any other option. Quote Link to comment Share on other sites More sharing options...
gin Posted November 14, 2007 Share Posted November 14, 2007 *winces* well that's your perogative, really. I just hope for your sake you don't have to add users or change their colours too often. As for the date... I'd suggest you test it out around Dec 31, Jan 1. I suspect you'll be very unhappy with the result. I reiterate, strtotime(). Quote Link to comment Share on other sites More sharing options...
Sleeper Posted November 14, 2007 Author Share Posted November 14, 2007 actuly adding users its a time sheet form you type in the name its there the font color is relitive to the config both of those will be easy to add and remove in seconds. Also the comment about Dec 31 vrs the Jan1 12/31/07 will still be less then 01/01/08 so the <= will still take place I dont see the issue there. I dont want a string I want the date layout to be compaired to a from entry. but ty for your concerns. I relize as I am a nube its hard for me to explain things that im thinking on here so I think its just a misunderstanding as to what good the strtotime() would be. Quote Link to comment Share on other sites More sharing options...
gin Posted November 14, 2007 Share Posted November 14, 2007 date() outputs a string, so you will be comparing two strings. 01/01/08 will definitely be less than 12/31/07. Try it and see. Sorry, I didn't mean strtotime(), I meant mktime(). It changes the date to a Unix timestamp. If in the future you do pick up CSS, please remember this conversation so you can laugh at yourself Also, I suggest loops. You shouldn't need to repeat the same code 77 times Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted November 14, 2007 Share Posted November 14, 2007 You can use the strtotime() function also. I find it easier to use than the mktime() function. To see that your comparison of sting dates won't work, please run this code: <?php $start = strtotime('12/01/2007'); $end = strtotime('02/01/2009'); for ($test = $start;$test <= $end; $test += 86400) { $test1 = $test + 86400; echo date('m/d/y',$test) . ' < ' . date('m/d/y',$test1) . ' ---> '; $t = (date('m/d/y',$test) < date('m/d/y'))?'True':'False'; echo $t . "<br>\n"; } ?> Ken Quote Link to comment Share on other sites More sharing options...
Sleeper Posted November 14, 2007 Author Share Posted November 14, 2007 as I said im a nube. Im not sure how to do loops yet but im sure ill learn. Ive recently become disables do to back issues so I have to learn a new carreer. Working on houses and cars is not a workable thing for me anymore. So im applying my self to this. been doing html on and off for 10 years. If I use the unix timestap I have nothing to compair it to. there is a form field option for date So they will input in say tuesdays date2 box 11/13/07 so the value of $date2=11/13/07 how am I to compair that to a unix time stamp like the mktime() produces of 1194936517. Also I would think the 08 at the end of the string would make the vaule larger then that ending with 07. And as I was typing this Ken put his post in. ken im a nube remember...lol thats all greek to me right now. Quote Link to comment Share on other sites More sharing options...
gin Posted November 14, 2007 Share Posted November 14, 2007 Seriously, the PHP manual is your friend. You should download it and start looking up stuff. www.php.net/docs.php The beginner tutorials on this site are also good. I learnt a lot from them. mktime() without any arguments will return the timestamp of the current datetime. You can use if (strtotime($date1) <= mktime()) color="$m1fc"; else color="#000000"; Comparing string compares the info as if they were a sentence, it doesn't know it's a date. It starts at the first letter/number. For 01/01/08, the first numerical is 0. For 12/31/07, the first numerical is 1. Therefore 01/01/08 is less than 12/31/07. It won't even bother to check the other numbers. Similarly, when comparing STRINGS, 123 is less than 55. But when comparing NUMBERS, 55 is less than 123. The idea of mktime() & strtotime() is to take a date (in a string format) and turn it into a number. Quote Link to comment Share on other sites More sharing options...
Sleeper Posted November 14, 2007 Author Share Posted November 14, 2007 Ty gin that just about worked, I ended up doing this basicly: <?php include ("admin/config.php"); include ("data_timesheet2.php"); $d=strtotime(tm_mon/tm_mday/tm_year); //FC1 if ($d <= strtotime($date1)) $fc1="$m1fc"; else $fc1="$fontcolor2"; ?> and that worked perfict. The mktime() for some reason made a number larger then the date so it was jumping ahead a bit to much. Also someone said somthing about looping? how would this be able to be looped as each one is a differnt option. like this... //FC1 if ($d <= strtotime($date1)) $fc1="$m1fc"; else $fc1="$fontcolor2"; //FC2 if ($d<=strtotime($date1)) $fc2="$m2fc"; else $fc2="$fontcolor2"; //FC3 if ($d<=strtotime($date1)) $fc3="$m3fc"; else $fc3="$fontcolor2"; //FC4 if ($d<=strtotime($date1)) $fc4="$m4fc"; else $fc4="$fontcolor2"; //FC5 if ($d<=strtotime($date1)) $fc5="$m5fc"; else $fc5="$fontcolor2"; //FC6 if ($d<=strtotime($date1)) $fc6="$m6fc"; else $fc6="$fontcolor2"; //FC7 if ($d<=strtotime($date1)) $fc7="$m7fc"; else $fc7="$fontcolor2"; //FC8 if ($d<=strtotime($date1)) $fc8="$m8fc"; else $fc8="$fontcolor2"; //FC9 if ($d<=strtotime($date1)) $fc9="$m9fc"; else $fc9="$fontcolor2"; //FC10 if ($d<=strtotime($date1)) $fc10="$m10fc"; else $fc10="$fontcolor2"; //FC11 if ($d<=strtotime($date1)) $fc11="$m11fc"; else $fc11="$fontcolor2"; //tu1 if ($d<=strtotime($date2)) $tu1="$tu1fc"; else $tu1="$fontcolor2"; //tu2 if ($d<=strtotime($date2)) $tu2="$tu2fc"; else $tu2="$fontcolor2"; //tu3 if ($d<=strtotime($date2)) $tu3="$tu3fc"; else $tu3="$fontcolor2"; //tu4 if ($d<=strtotime($date2)) $tu4="$tu4fc"; else $tu4="$fontcolor2"; //tu5 if ($d<=strtotime($date2)) $tu5="$tu5fc"; else $tu5="$fontcolor2"; //tu6 if ($d<=strtotime($date2)) $tu6="$tu6fc"; else $tu6="$fontcolor2"; //tu7 if ($d<=strtotime($date2)) $tu7="$tu7fc"; else $tu7="$fontcolor2"; //tu8 if ($d<=strtotime($date2)) $tu8="$tu8fc"; else $tu8="$fontcolor2"; //tu9 if ($d<=strtotime($date2)) $tu9="$tu9fc"; else $tu9="$fontcolor2"; //tu10 if ($d<=strtotime($date2)) $tu10="$tu10fc"; else $tu10="$fontcolor2"; //tu11 if ($d<=strtotime($date2)) $tu11="$tu11fc"; else $tu11="$fontcolor2"; That is for the 11 time shifts on monday and tuesday and I had to do this threw sunday. which thanks to the wounder of edit/replace was a simple edit from gins code example. But i dont see how you could loop that. there are 11 time shifts each day and 7 days a week wach of those 77 shifts could have a differnt dj in it which in this set up would have a male/female/autodj color selection. so when they submit the form it wrights the form info for the font to the coresponding $coloroption Dont know but you can see the finished idea at http://www.webcityradio.com/timesheet.htm each timesheet is pulled in on an iframe and those are reverable by coding and then placed inside an html page all to look like a normal old html look. Quote Link to comment Share on other sites More sharing options...
gin Posted November 14, 2007 Share Posted November 14, 2007 As for the loop, look at the first 11, what is the difference? Just one number right? <?php for ($i=1; $i<=11; $i++) { if ($d <= strtotime($date1)) $fc1= ${'m'.$i.'fc'}; // a variable variable else $fc1="$fontcolor2"; } ?> Even 7 times is better than 77, right? And if you place this loop in another loop, you can get away with just one nested loop. Quote Link to comment Share on other sites More sharing options...
Sleeper Posted November 15, 2007 Author Share Posted November 15, 2007 ok im lost. I tried that gin and the first one worked and everyone after that the font just turned black instead of the $fontcolor2 I atached what I have for the auto change. each groupd would be the shifts for each day day one being monday. day 7 being sunday. then the last 7 are for the titals "Monday - Tuesday" so they change as the day rolls over as well. When I took out the first 11 and put in the code that you gave me i the last post gine like I said the first shift changed color, the rest where just a flat black. [attachment deleted by admin] 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.