Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

1 Neutral

About KillGorack

  • Rank
  • Birthday 11/22/1970

Profile Information

  • Gender
  1. KillGorack

    Previous, and next record (when NOT ordered by ID)

    I have to get my head around this but it seems SQL has some counting functionality. The code below works, 113 is the current ID we're looking at and the sql below will give previous, and next as well. From a coworker; WITH numberlist AS (SELECT ID, row_number() OVER (ORDER BY trk_airdate ASC) as RN from startrek) SELECT numberlist.* FROM numberlist WHERE RN IN (SELECT RN + i FROM numberlist CROSS JOIN (SELECT -1 AS i UNION ALL SELECT 0 UNION ALL SELECT 1) n WHERE ID = 113) ORDER BY RN wonderful
  2. KillGorack

    Previous, and next record (when NOT ordered by ID)

    I like this solution, but reordering the table isn't possible in my situation Even in this example data we have overlapping dates, which could cause skipping records? I will test this to be sure. <Off topic> In the early 90's DS9, and TNG aired at the same time, Then later in the same decade Voyager, and DS9 overlapped. </Off topic>
  3. SQL is made up below, but I have something similar sorted by dates, and NOT by ID. Currently I get this done by getting all the ID's in an array ordered by date and gleaning the two record ID's from that array. if the table is huge, that might not be the best way. Just seems like there should be an easier way to do it. Any ideas? Select startrek.ID, optc.opt_value as trk_series_id, optc.ID as trk_series_idID, startrek.trk_title, startrek.trk_episode, startrek.trk_season, startrek.trk_airdate, startrek.trk_stardate FROM startrek JOIN opt optc ON optc.ID = startrek.trk_series_id ORDER BY trk_airdate ASC
  4. KillGorack

    PHP TIME (NOT TIMEDATE) difference

    current code, a little better function sec_diff_time($s, $e){ if(!validateDate($s, "H:i:s") or !validateDate($e, "H:i:s")){ return false; }else{ $secsday = 86400; if(strtotime($s) <= strtotime($e)){ $secs = strtotime($e) - strtotime($s); }else{ $secs = (strtotime($e) + $secsday) - strtotime($s); } return $secs; } }
  5. Hi, Trying to figure out a way to get a time difference between two times assuming they are in order.. For example; in the array below the days is easy.. because the time happens later, however nights it becomes a little more confusing. The method I'm using now is; if the dates are in order just stick a reference date on there, and get a difference. If they seem to be reversed, I stick a reference date on the first one and a reference date +1 days on the second and get the difference. Can you all think of a better way? I will use the assumption that the times will NEVER be more than 24 hrs apart.. Array ( [2] => Array ( [days] => Array ( [0] => 07:00:00 [1] => 15:45:00 ) [nights] => Array ( [0] => 15:30:00 [1] => 02:15:00 ) )
  6. Sorry for the late reply! Thanks for that it works great. Better than my solution for sure.
  7. It's a bit tacky, but this is working so far, there has to be a better way. function getParameterByName(name, url) { if (!url) url = window.location.href; name = name.replace(/[\[\]]/g, '\\$&'); var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, ' ')); } if(getParameterByName('fn') == 'edit'){ var i; for(i = 1; i < 10; i++){ $('#datepicker' + i).datepicker({ format: 'yyyy/mm/dd', calendarWeeks: true, weekStart: 1, todayHighlight: true }); } } Edit below PHP with the incremental value on the end.. function element_date($field, $value){ if($field['fld_required'] == 1){ $rq = "required"; }else{ $rq = ""; } $rtrn = "<div class=\"form-group row m-0\">"; $rtrn .= "<label class=\"col-sm-4 col-form-label\">".$field['fld_human']."</label>"; $rtrn .= "<div class=\"col-sm-8 text-right p-0\">"; $rtrn .= "<input id=\"datepicker".$this->datecounter."\" type=\"text\" class=\"form-control form-control-sm\" name=\"".$field['fld_fieldname']."\" value=\"".$value."\" ".$rq." placeholder=\"YYYY-MM-DD\">"; $rtrn .= "</div>"; $rtrn .= "</div>"; $this->datecounter = $this->datecounter + 1; return $rtrn; }
  8. JQuery 3.3.1, Bootstrap 4.2.1, and the use of the Bootstrap Datepicker We’re trying to get satisfy some “Content Security Policy” requirements. One of which is to remove the java in the code, and call it from a known js file somewhere. That said I need to place the stuff in a js file which DOES work, but we have to place some java for EACH datepicker, or datetimepicker that exists in the site (which is scalable) so these form elements need to be added from time to time, and as it stands now we’ll need to add to the JS file also. I’m an absolute tool when it comes to js just FYI. To the question; Is there a way to code the JAVA below so it can handle ALL datepickers once? In the past we would write the form element and the js together, so the id's could be created on the fly. With a js file, it complicates things. $('#datepicker').datepicker({ format: 'yyyy/mm/dd', calendarWeeks: true, weekStart: 1, todayHighlight: true });
  9. KillGorack

    cookie samesite flag causing warning

    Thanks for the reply, I have access to 7.3, but the production server is 7.2. Does this make a difference? This is of course I think because the presence of the semicolon below within the "samesite" attribute. session_set_cookie_params(0, "/; SameSite=Strict", "domain.com", true, true); Looking for syntax of that array method. Can you help a guy out with an example?
  10. Hi, Playing with hardening a little, and implemented samesite flag within a cookie, or at least tried to. Code like: session_set_cookie_params(0, "/; SameSite=Strict", "domain.com", true, true); $params = session_get_cookie_params(); session_start(); setcookie("PHPSESSID", session_id(), $params["lifetime"], $params["path"], $params["domain"], $params["secure"], $params["httponly"]); Warning: PHP Warning: Cookie paths cannot contain any of the following ',; \t\r\n\013\014' in /homepages/39/d582945504/htdocs/portal-x/inc/cookies.php on line 21 Not sure if it's a huge deal to just leave that out..
  11. KillGorack

    Filter array by KEY

    great also changed the code from the last second on Sunday to the first on Monday. looks like that works. I appreciate the help, thanks.
  12. KillGorack

    Filter array by KEY

    Walked around array_filter for a while, never seen the ability to put that tag there. thanks!
  13. KillGorack

    Filter array by KEY

    It's a little reckless, but I'm implementing the loop like this. $d = date('Y-m-d', strtotime('last Sunday', strtotime(date('Y-m-d')))); $d = $d." 23:59:59"; foreach($combine as $key => $b){ if(strtotime($key) >= strtotime($d)){ unset($combine[$key]); } } A filter that does the same would be awesome..
  14. KillGorack

    Filter array by KEY

    I would like to create an array from the one below that can sort of filter using date ranges; For example, make an array that contains data using date <= 2018-05-09 without a loop. A loop is an option just wondering if you can filter by keys somehow. Array ( [2018-04-23 21:31:40] => -1.174 [2018-04-24 15:43:59] => -1.015 [2018-04-26 00:14:10] => -0.37 [2018-04-30 18:41:51] => -1.042 [2018-05-01 20:08:40] => -0.72 [2018-05-02 22:11:52] => -0.107 [2018-05-07 18:40:12] => -0.298 [2018-05-09 16:35:38] => -0.36 [2018-05-10 01:14:27] => 0.408 [2018-05-14 20:49:54] => 1.549 )
  15. KillGorack

    Load canvas after ajax call

    I can foresee this being an issue when/if I get anything to draw in there to begin with. I'm not sure how to call a blanking of the canvas with an ajax call. Perhaps answering that question will result in a way to also draw with t he ajax function.

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.