<html> <head> <link rel="stylesheet" type="text/css" href="bootstrap/dist/css/bootstrap.min.css"> </head> <h2>Employees</h2> <?php require_once('Util.php'); if (empty($_GET)) { ?> <form class="form-horizontal" role="form" action='employees_table.php' method='get'> <div class="form-group"> <label for="last_name" class="col-sm-offset-2 control-label">Last Name</label> <input type="text" name="last_name"/><br> <label for="first_name" class="col-sm-offset-2 control-label">First Name</label> <input type="text" name="first_name"/><br> </div> <div class="col-sm-offset-2 col-sm-10"> <input type="submit" value="Suchen" class="btn"/> </div> </form> <?php } else { $last_name = $_GET['last_name']; $first_name = $_GET['first_name']; $db = oci_connect('hr', 'hr', 'kurs2.wifi'); $sql = "select first_name, last_name, salary, email, hire_date from employees where "; if (!empty($last_name)) { $sql .= " last_name = :b_last_name and"; } if (!empty($first_name)) { $sql .= " first_name = :b_first_name and"; } $sql .= ' 1=1'; $q = oci_parse($db, $sql); if (!empty($last_name)) { oci_bind_by_name($q, ":b_last_name", $last_name ); } if (!empty($first_name)) { oci_bind_by_name($q, ":b_first_name", $first_name ); } $r = oci_execute($q, OCI_DEFAULT); $table = array(); while ($row = oci_fetch_array($q, OCI_NUM)) { $table[] = $row; } $headers = array('First Name', 'Last Name', 'Salary', 'Email', 'Hire Date'); print_table($table, $headers); } ?> </html>