This shows you the differences between two versions of the page.
|
kurs:employees_per_department [2014/12/15 13:58] mh created |
kurs:employees_per_department [2014/12/16 12:34] (current) mh |
||
|---|---|---|---|
| Line 97: | Line 97: | ||
| === Employees per Department mit jquery aktualisieren === | === Employees per Department mit jquery aktualisieren === | ||
| - | <code> | + | <code><html> |
| - | <html> | + | |
| <head> | <head> | ||
| <link rel="stylesheet" type="text/css" | <link rel="stylesheet" type="text/css" | ||
| href="bootstrap/dist/css/bootstrap.min.css"> | href="bootstrap/dist/css/bootstrap.min.css"> | ||
| + | <script src="jquery-2.1.1.min.js"></script> | ||
| + | |||
| + | |||
| </head> | </head> | ||
| - | <h2>Employees</h2> | + | |
| <?php | <?php | ||
| + | require_once('Config.php'); | ||
| require_once('Util.php'); | require_once('Util.php'); | ||
| $db = oci_connect('hr', 'hr', 'kurs2.wifi'); | $db = oci_connect('hr', 'hr', 'kurs2.wifi'); | ||
| if (empty($_GET)) { | if (empty($_GET)) { | ||
| - | $sql = "select department_id id, | + | $sql = "select department_id, |
| department_name | department_name | ||
| from departments where department_id in | from departments where department_id in | ||
| Line 116: | Line 119: | ||
| $r = oci_execute($q, OCI_DEFAULT); | $r = oci_execute($q, OCI_DEFAULT); | ||
| $table = array(); | $table = array(); | ||
| - | while ($row = oci_fetch_array($q, OCI_ASSOC)) { | + | while ($row = oci_fetch_array($q, OCI_NUM)) { |
| $table[] = $row; | $table[] = $row; | ||
| } | } | ||
| | | ||
| ?> | ?> | ||
| - | + | <script> | |
| - | <form class="form-horizontal" role="form" | + | |
| - | action='employees_departments.php' method='get'> | + | $(function () { |
| + | $( "#depselect" ).change(function() { | ||
| + | $.get("http://localhost/employees_departments_js.php?department="+ | ||
| + | $( this ).val(), function( data ) { | ||
| + | $("#output").html( data ); | ||
| + | }); | ||
| + | }); | ||
| + | }); | ||
| + | </script> | ||
| + | |||
| + | <h2>Select Department</h2> | ||
| <div class="form-group"> | <div class="form-group"> | ||
| - | <select class="col-sm-offset-2 col-sm-3" name='department'> | + | <select id='depselect' class="col-sm-offset-2 col-sm-3" name='department'> |
| <?php foreach ($table as $dep) { | <?php foreach ($table as $dep) { | ||
| - | printf("<option value='%s'>%s</option>\n", | + | printf("<option value='%s'>%s</option>\n", $dep[0], $dep[1]); |
| - | $dep['ID'], $dep['DEPARTMENT_NAME']); | + | |
| } | } | ||
| ?> | ?> | ||
| - | </select> | + | </select> |
| - | | + | <br> |
| - | </div> | + | <div id='output'> |
| - | <div class="col-sm-offset-2 col-sm-10"> | + | |
| - | <input type="submit" value="Suchen" class="btn"/> | + | |
| </div> | </div> | ||
| </form> | </form> | ||
| Line 142: | Line 152: | ||
| } else { | } else { | ||
| $department_id = $_GET['department']; | $department_id = $_GET['department']; | ||
| + | |||
| + | |||
| $sql = "select first_name, | $sql = "select first_name, | ||
| last_name, | last_name, | ||
| Line 168: | Line 180: | ||
| ?> | ?> | ||
| </html> | </html> | ||
| + | | ||
| </code> | </code> | ||
| - | < | + | |