mardi 28 juillet 2015

Else part not running inside a while(next()) loop in jsp

I want to create a table to show if a class occupied or empty in a certain hour of day. The code executes the if part. But when the if condition is not satisfied, else part does not execute either.

                        <td><%
                    String Hours = "07:00:00";
                    String sql1 = ("SELECT * FROM booked_classrooms WHERE block ='"+blockNo+"' AND room_no='"+roomNo+"' AND startTime='"+today+" "+Hours+"';");
                    boolean checkSql1 = false;

                    checkSql1 = st.execute(sql1);

                    if(!checkSql1){%>No Class<% }

                    else{
                        rs = st.executeQuery(sql1);

                    while(rs.next()){
                    Date classStart = sdf1.parse(rs.getString(6));
                      Date routineStartHour = sdf1.parse(today+" "+Hours);


                      c.setTime(classStart);
                    int dow1 = c.get(Calendar.DAY_OF_WEEK);

                       if(dow1 == dow){
                    %>
                    <%=rs.getString(3)%> by <%=rs.getString(2) %><%

                       }else{ %>No Class<%
                       } } 
                     } %></td>

Aucun commentaire:

Enregistrer un commentaire