1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
<form action="" method="get">
<input type="text" name="q" class="input-block-level">
</form>
<table id="example" class="table table-striped table-hover">
<thead>
<tr>
<th>NUMEROS MATRICULE</th>
<th>NOM</th>
<th>GRADE </th>
<th>DATE EFFET</th>
<th>ACTION</th>
</tr>
</thead>
<tbody>
<%
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connexion = DriverManager.getConnection("jdbc:mysql://localhost:3306/projetgrh", "root", "");
Statement stm = connexion.createStatement();
String req = request.getParameter("q");
String query;
if (req!=null) {
query = "SELECT n_mat, nom, code_grade, date_effet FROM carriere where code_grade = 'STAGIAIRE' and ('%"+req+"%' -
EXTRACT(YEAR FROM date_effet)) = 1 ";
}else{
query = "SELECT n_mat, nom, code_grade, date_effet FROM carriere where code_grade = 'STAGIAIRE' and
TIMESTAMPDIFF(YEAR,date_effet,NOW()) = 1 ";
}
ResultSet rs = stm.executeQuery(query);
while (rs.next()) {
%>
<tr>
<td><%=rs.getString("n_mat")%></td>
<td><%=rs.getString("nom")%></td>
<td><%=rs.getString("code_grade")%></td>
<td><%=rs.getString("date_effet")%></td>
</tr>
<%
}
} catch (Exception ex) {
ex.printStackTrace();
}
%>
</tbody>
</table> |
Partager