Jump to content

mrplatts

Members
  • Posts

    18
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mrplatts's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. alright I'm convinced.  I'll rewrite a little, it will make life much easier. Rich
  2. Hmm... I did save them in MYSQL date format yyyy-mm-dd, but it would make much more sense to use timestamps for this reason.  Also, I find myself going back and forth from timestamps to that date format annoying.  Pretty silly when I can just use date("d-m-Y", $stamp); So there isn't an easy way to order by date? why have a specific format for date in MySQL then??
  3. I have a MySQL table keyed by date.  In my script I want to find out the last date in the table.  (they are sequetial) I can't seem to find anything online to help. I just need to get the date field from the row at the end of the sequence. Thanks, Rich
  4. I'm using a simple calendar display with using [code] <?php for($m=8; $m<=12; $m++) { $date_month = $m; $date_year = 2006; $theday = date(w, mktime(0, 0, 0, $date_month, 1, $date_year)); $daysinmonth = date("t", mktime(0, 0, 0, $date_month, 1, $date_year)); echo "<table align=center border=0>"; echo "<tr>><td colspan=7 align=center>".date("F", mktime(0, 0, 0, $date_month, 1, $date_year))." (".date("Y", mktime(0, 0, 0, $date_month, 1, $date_year)).")</td></tr>"; echo "<tr>"; echo "<td>Sun</td>"; echo "<td>Mon</td>"; echo "<td>Tue</td>"; echo "<td>Wed</td>"; echo "<td>Thu</td>"; echo "<td>Fri</td>"; echo "<td>Sat</td>"; echo "</tr>"; echo "<tr>"; for ($i=0;$i<$theday;$i++) {   echo "<td>&nbsp;</td>"; } for ($list_day=1;$list_day<=$daysinmonth;$list_day++) { ?> [/code] ... well you get the idea. I want to start showing the date at a specified start month and end display with a specified end month, in the next year.  Is there a way to loop this efficiently?  I know I could do it with a convoluted set of loops. More specifially, for example it would display from august 2006 -- June 2007.
  5. Ok, I played with the math & fully understand how you used % to solve my problem. Thanks so much
  6. I've been puzzling out this issue and am not exactly sure how to do it. My project (so far...) ([url=http://www.mrplatts.com/sched/cal_setup.html]http://www.mrplatts.com/sched/cal_setup.html[/url]) User puts in a start date, then an end date, the begining rotation day and exceptions to the days The exceptions dump into an array & a function assigns the weekdays a rotating number 1-6, unless it is an exception This will set up the basic calendar for an entire year for a school's day-roation.  The point----------------> After the form has processed & made a a table, I plan on allowing the user to choose a day type (Holiday, Clerical, Inservice)  I don't want the code to get über-complicated... I suppose it might just be a matter of carrying over the posted data to the third submission, maybe you can suggest an efficient way to do it. Eventually it would be submitted to a mySQL database.  Would it be easier to submit the data at first & then modify it when it is in the database, instead of trying to do it all before inserting it?  Rich
  7. ??? I understand that I transposed the units in the example I gave... 3%7=1 OK -- this is the  code below...  I think I follow the example given by printf but am not sure if it applies to this example exactly.  Like I said, it works perfectly.  Before I got the idea from someone on this forum, I had a cumbersome set of if checks to reset to one if the rotation number reached 7.  Since this is way sleeker I want to 'get it' [code] <?php function rotation_inc(&$r, $current_date, $excepts) //rotation, $day of week { $t = date("Y-m-d", $current_date);//mySQL formatted date yyyy-mm-dd $d = date('w',$current_date);      //gives day of week a number value 0 - 6 if (!in_array($t, $excepts) && $d != 0 && $d != 6){  //check to see if day is weekend or non-school day echo $r; //display the rotation number $r =$r++ % 6 + 1; //increment the number if it is 6, return it to 1 } else { echo '<font color="#ff0000">NONE</Font>'; //when there is no rotation day, display this } } ?> [/code]
  8. Bear with me, I'm learning I understand what modulus is, and the basic workings of it ie [edit] 3  %7 is 1 OK, Why does this: [code]$r =$r++ % 6 + 1; [/code] increment 1, 2, 3, 4, 5, 6, 1, 2, 3 ,4, 5, 6 I got it from someone on here & it works great.  I want to know why. Maybe I don't understand the order of operations in this case... Rich
  9. Thanks for your help.  now I know what to look for!
  10. I am using jedit (MAC OS X) , the syntax highlighting seems pretty messed up. Apparently as soon as I started using an array the => messed up the syntaxing.  I'l check it out on UltraEdit on my PC. --or squint at the code for a bit. Rich
  11. I'm getting an error: Parse error: parse error, unexpected $ in /home3/mrplatts/mrplatts-www/sched/cal_setup.html on line 161 I can't for the life of me figure out how i've got an error on that line since my file ends on line 160. Is this common? Rich
  12. I've written a script to set up calendar for a six-day rotating schedule.  With some help here, I've written the code to get it basically working.  here's my issue: I assign a date using [code] $s = mktime (0,0,0,$sm, $sd, $sy);  [/code] Then display it using [code] print date('Y-m-d',$s); [/code] The timestamp that prints in the next column when I display [code] echo '<td>'.$s.'</td>'; [/code] Is alwas exactly one hour off, Is there some sort of correction I need to do for DST? In fact, when I check it agains unixtimestamp.com. it is always a different date that appears. Oh, additionally, after about two months of dates a date repeats.  (I'm adding 86400 to increment one day.) Sample output: 2006-08-24 Thursday1156392000 2006-08-25 Friday   1156478400 2006-08-26 Saturday156564800 2006-08-27 Sunday 1156651200 2006-08-28 Monday 1156737600 Very grateful for your input! Rich
  13. I implemented the idea above, it made sense to me... I wrote: [code]$excepts = $HTTP_POST_VARS['exceptions']; if($excepts){ $excepts[] = explode("\n",add_slashes($_POST['exceptions'])); foreach ($excepts as $field => $label) { list($xm, $xd, $xy) = explode("-", $label); // seperate the month, date & year $label = $xy."-".$xm."-".$xd; / reassemble in MySQL format } }[/code] And I got: Fatal error: Call to undefined function: add_slashes() in /home3/mrplatts/mrplatts-www/sched/cal_setup.html on line 28 I'm not really sure if the way I wrote it puts it back into the same spot on the array. Usually I mess with it until it does what I want. Rich
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.