Jump to content

KillGorack

Members
  • Content count

    37
  • Joined

  • Last visited

Community Reputation

0 Neutral

About KillGorack

  • Rank
    Member
  • Birthday 11/22/1970

Profile Information

  • Gender
    Male
  1. 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.
  2. KillGorack

    Filter array by KEY

    Walked around array_filter for a while, never seen the ability to put that tag there. thanks!
  3. 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..
  4. 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 )
  5. 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.
  6. KillGorack

    Load canvas after ajax call

    Page load I think calls the stuff like drawing canvas and the like, the problem here is that I don't know how to call the canvas to load after an ajax call. I can create the data I need, and see exactly what is expected, it's just the canvas isn't loading. <edit>The canvas div is visible, it's just not drawing what is within.</edit> Form <form METHOD="POST" ACTION=""> Project <select name="fm_project" onchange="showdata(this.form)" id="fm_project"> <option value="2">Project A</option> <option value="1">Project B</option> <option value="3">Project C</option> <option value="0" SELECTED>Select One</option></select> Module <select name="fm_module" onchange="showdata(this.form)" id="fm_module"> <option value="194">B</option> <option value="195">C</option> <option value="197">D</option> <option value="196">E</option> <option value="0" SELECTED>Select One</option></select> Stage <select name="fm_stage" onchange="showdata(this.form)" id="fm_stage"> <option value="201">stagea</option> <option value="202">stageb</option> <option value="203">stage3</option> <option value="0" SELECTED>Select One</option></select> Part <select name="fm_part" onchange="showdata(this.form)" id="fm_part"> <option value="1">Part1</option> <option value="2">Part2</option> <option value="3">part3</option> <option value="0" SELECTED>Select One</option></select> </form> <div id="graph_field">Start by choosing some filters above..</div> JS <script> function showdata(form){ var xhttp, project = form.fm_project.value, module = form.fm_module.value, stage = form.fm_stage.value, partno = form.fm_part.value; if (project == "") { document.getElementById("graph_field").innerHTML = ""; return; } if (module == "") { document.getElementById("graph_field").innerHTML = ""; return; } if (stage == "") { document.getElementById("graph_field").innerHTML = ""; return; } if (partno == "") { document.getElementById("graph_field").innerHTML = ""; return; } xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("graph_field").innerHTML = this.responseText; } }; xhttp.open("GET", "printme.php?app=projects&ala=csajax&fm_project="+project+"&fm_module="+module+"&fm_stage="+stage+"&fm_part='"+partno+"'", true); xhttp.send(); } </script> canvas in the Ajax call refereed in the xhttp.open line above. <canvas id="myCanvas" width="970" height="200"></canvas> <script> var canvas = document.getElementById('myCanvas'); var ctx = canvas.getContext('2d'); do stuff... </script> Thanks!
  7. KillGorack

    Ajax, multiple form elements

    Amazing simple and quick, thanks!
  8. KillGorack

    Ajax, multiple form elements

    New to Ajax, and BAD with the scripting below, bare with me. Looking to select a drop down and push all values to the query string at the end. Works perfectly with ONE select element. I just have no idea how to separate the variables. The code below is putting whatever form element I change into the first "str" variable. if possible if one of the elements below is changed, all three of variables the data is placed in the query string in the correct place if that makes sense. Form <form> <table style="width:100%"> <tr> <td style="width:85px;"> Project </td> <td style="text-align:right;"> <select name="fm_project" class="allform_select" onchange="showdata(this.value)"> <option value="2" >ProjectA</option> <option value="1" >ProjectB</option> <option value="3" >ProjectC</option> <option value="0" SELECTED>Select One</option> </select> </td> </tr> <tr> <td style="width:85px;"> Module </td> <td style="text-align:right;"> <select name="fm_module" class="allform_select" onchange="showdata(this.value)"> <option value="194" >B</option> <option value="195" >C</option> <option value="197" >D</option> <option value="196" >E</option> <option value="0" SELECTED>Select One</option></td> </select> </tr> <tr> <td style="width:85px;"> Stage </td> <td style="text-align:right;"> <select name="fm_stage" class="allform_select" onchange="showdata(this.value)"> <option value="201" >BLUE</option> <option value="202" >GREEN</option> <option value="203" >RED</option> <option value="0" SELECTED>Select One</option> </select> </td> </tr> </table> </form> Script <script> function showdata(str, stra, strb) { var xhttp; if (str == "") { document.getElementById("graph_field").innerHTML = ""; return; } if (stra == "") { document.getElementById("graph_field").innerHTML = ""; return; } if (strb == "") { document.getElementById("graph_field").innerHTML = ""; return; } xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("graph_field").innerHTML = this.responseText; } }; xhttp.open("GET", "printme.php?app=projects&ala=csajax&fm_project="+str+"&fm_module="+stra+"&fm_stage="+strb, true); xhttp.send(); } </script>
  9. KillGorack

    PHP mysqli bind_param

    Yea I know , it's sooo much easier and going back to mysqli is a headache....currently working with some older code.. until I get everything switched over, it's not an option. investigating using "call_user_func_array" currently..
  10. KillGorack

    PHP mysqli bind_param

    Is there a way to bind parameters in a select SEPARATELY? I know how to do this in one line, but would like some direction on how to do this one line at a time, OR means to stick that array into the bind_param line where it will work with different array lengths. using mysqli to modify some older code. Understanding of course that the ?'s count must match the amount of parameters. End result to make a generic reader function. $sql = "SELECT ID, foo, bar FROM table WHERE ID = ? AND bar = ?"; $vars[] = array('typ' => "i", 'vlu' => $id); $vars[] = array('typ' => "s", 'vlu' => $rkey); $stmt = $db->prepare($sql); foreach($vars as $var){ $stmt->bind_param($var['typ'], $var['vlu']); } $stmt->execute(); $res = $stmt->get_result(); $rows = $res->fetch_array(MYSQLI_ASSOC);
  11. KillGorack

    Left joins not being implemented correctly?

    Just FYI, here's the first version of that loop. Creates the joins for seven separate tables, they all work. Whoot! Please ignore the darn typo. <?php // ================================================================================= // Build the sql // ================================================================================= $a = range('a', 'z'); $jn = ""; $ac = 0; foreach($fldarray as $fld){ if($fld['enabeled'] == 1 and $fld['index'] = 1){ $nm[] = $fld['human']; if($fld['opt'] == 1){ if($fld['opt_table'] <> "" and $fld['opt_field'] <> ""){ $jn .= " LEFT JOIN ".$fld['opt_table']." "."Tbl".$a[$ac]." ON "."Tbl".$a[$ac].".ID = ".$ap.".".$fld['fieldname']; $fd[] = "Tbl".$a[$ac].".".$fld['opt_field']." as Opt_".$a[$ac]; }else{ $jn .= " LEFT JOIN opt "."Tbl".$a[$ac]." ON "."Tbl".$a[$ac].".ID = ".$ap.".".$fld['fieldname']; $fd[] = "Tbl".$a[$ac].".opt_value as Opt_".$a[$ac]; } $ac = $ac + 1; }else{ $fd[] = $ap.".".$fld['fieldname']; } } } $sql = "SELECT ".implode(", ", $fd)." FROM ".$ap.$jn; // ================================================================================= // Column Headers // ================================================================================= echo "<table class=\"cells\">"; echo "<tr>"; echo "<td class=\"topper\">".implode("</td><td class=\"topper\">", $nm)."</td>"; echo "</tr>"; // ================================================================================= // The data // ================================================================================= $stmt = $db->query($sql); $data = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach($data as $datum){ echo "<tr><td class=\"topper\">".implode("</td><td class=\"topper\">", $datum)."</td></tr>"; } // ================================================================================= // Cap it off // ================================================================================= echo "</table>"; // ================================================================================= ?> Still needs some tweaks, and what-nots. but it's working.
  12. KillGorack

    Left joins not being implemented correctly?

    Yea I think so, I know what the join is supposed to look like, now I get to try and get that into something that can handle a few different tables. All in all my issue wasn't with how to cram text together, it was needing to have a workable example to start with. With that example I'll be good.
  13. KillGorack

    Left joins not being implemented correctly?

    Thanks! I'll work that into the loop. I'll push forward on the joins, I'm fairly new to them. yea lol it's even in the table spelled that way. Thanks for pointing that out. This is an instance of a typo that is replicated via copy and paste..
  14. KillGorack

    Left joins not being implemented correctly?

    Well I have no errors, but now when i use the PDO::FETCH_ASSOC it doesn't fetch the values I'm getting with the joins. The code; <?php error_reporting(E_ALL); ini_set('display_errors', '1'); $sql = "SELECT app.app_name, app.app_var, Tbla.opt_value, Tblb.opt_value, app.app_enabeled, app.app_admin FROM app LEFT JOIN opt Tbla ON Tbla.ID = app.app_landing LEFT JOIN opt Tblb ON Tblb.ID = app.app_type"; $stmt = $db->query($sql); $data = $stmt->fetchall(PDO::FETCH_BOTH); echo "<pre>"; print_r($data); echo "</pre>"; ?> Results; PDO::FETCH_ASSOC Array ( [0] => Array ( [app_name] => Applications [app_var] => app [opt_value] => DB Table [app_enabeled] => 1 [app_admin] => 1 ) [1] => Array ( [app_name] => Users [app_var] => usr [opt_value] => DB Table [app_enabeled] => 1 [app_admin] => 1 ) [2] => Array ( [app_name] => Permissions [app_var] => acs [opt_value] => DB Table [app_enabeled] => 1 [app_admin] => 1 ) [3] => Array ( [app_name] => Benchmark [app_var] => benchmark [opt_value] => DB Table [app_enabeled] => 1 [app_admin] => 1 ) [4] => Array ( [app_name] => News [app_var] => nws [opt_value] => DB Table [app_enabeled] => 1 [app_admin] => 1 ) [5] => Array ( [app_name] => Test Bench [app_var] => test [opt_value] => DB Table [app_enabeled] => 1 [app_admin] => 1 ) [6] => Array ( [app_name] => Fields [app_var] => fld [opt_value] => DB Table [app_enabeled] => 0 [app_admin] => 1 ) [7] => Array ( [app_name] => Settings [app_var] => stg [opt_value] => DB Table [app_enabeled] => 1 [app_admin] => 1 ) ) PDO::FETCH_BOTH Array ( [0] => Array ( [app_name] => Applications [0] => Applications [app_var] => app [1] => app [opt_value] => DB Table [2] => Index [3] => DB Table [app_enabeled] => 1 [4] => 1 [app_admin] => 1 [5] => 1 ) [1] => Array ( [app_name] => Users [0] => Users [app_var] => usr [1] => usr [opt_value] => DB Table [2] => Index [3] => DB Table [app_enabeled] => 1 [4] => 1 [app_admin] => 1 [5] => 1 ) [2] => Array ( [app_name] => Permissions [0] => Permissions [app_var] => acs [1] => acs [opt_value] => DB Table [2] => Index [3] => DB Table [app_enabeled] => 1 [4] => 1 [app_admin] => 1 [5] => 1 ) [3] => Array ( [app_name] => Benchmark [0] => Benchmark [app_var] => benchmark [1] => benchmark [opt_value] => DB Table [2] => DB Table [3] => DB Table [app_enabeled] => 1 [4] => 1 [app_admin] => 1 [5] => 1 ) [4] => Array ( [app_name] => News [0] => News [app_var] => nws [1] => nws [opt_value] => DB Table [2] => Index [3] => DB Table [app_enabeled] => 1 [4] => 1 [app_admin] => 1 [5] => 1 ) [5] => Array ( [app_name] => Test Bench [0] => Test Bench [app_var] => test [1] => test [opt_value] => DB Table [2] => Index [3] => DB Table [app_enabeled] => 1 [4] => 1 [app_admin] => 1 [5] => 1 ) [6] => Array ( [app_name] => Fields [0] => Fields [app_var] => fld [1] => fld [opt_value] => DB Table [2] => Index [3] => DB Table [app_enabeled] => 0 [4] => 0 [app_admin] => 1 [5] => 1 ) [7] => Array ( [app_name] => Settings [0] => Settings [app_var] => stg [1] => stg [opt_value] => DB Table [2] => Index [3] => DB Table [app_enabeled] => 1 [4] => 1 [app_admin] => 1 [5] => 1 ) )
  15. KillGorack

    Left joins not being implemented correctly?

    Trying to implement, stay tuned.. of this above I have no doubt.
×

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.