I have a database. Now I want to show it's value in a table. So the table's row will be visible only if a particular column have to show some value from database. My database looks like below:
+--------+------+------------+---------+------+---------+---------+--------+---------+---------+--------+---------+---------+--------+
| c_name | c_id | cs_date | t_marks | nos | s_name1 | s_roll1 | marks1 | s_name2 | s_roll2 | marks2 | s_name3 | s_roll3 | marks3 |
+--------+------+------------+---------+------+---------+---------+--------+---------+---------+--------+---------+---------+--------+
| 22 | 22 | 2019-11-04 | 44 | 2 | A1 | 01 | 22 | A2 | 02 | 22 | | | |
+--------+------+------------+---------+------+---------+---------+--------+---------+---------+--------+---------+---------+--------+
Now this is the below jsp page which I have tried:
<%@page import="beans.*"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script>
function showRow(){
for(var i=1;i<=3;i++){
var rownum=document.getElementById("classrow"+1);
if(document.getElementById("sroll"+1)==""){rownum.style.display='block';}
else{rownum.style.display='none';}
}
}
</script></head>
<body>
<%
class1 classd = (class1)session.getAttribute("classd");
if(classd != null){
%>
<table align="center"><tr>
<th>Class<br>Name</th>
<th>Class<br>Total Marks</th>
<th>Class<br>Start Date<br>(Class ID)</th>
<th>Student<br>Name</th>
<th>Student<br>Roll</th>
<th>Student<br>Marks</th></tr>
<tr id="classrow1" style='display:none'>
<td><%=classd.getCname() %></td>
<td><%=classd.getTmarks() %></td>
<td><%=classd.getCsdate() %> (<%=classd.getCid() %>)</td>
<td><%=classd.getSname1() %></td>
<td id="sroll1"><%=classd.getSroll1() %></td>
<td><%=classd.getMarks1() %></td></tr>
<tr id="classrow2" style='display:none'>
<td></td>
<td></td>
<td><%=classd.getCsdate() %> (<%=classd.getCid() %>)</td>
<td><%=classd.getSname2() %></td>
<td id="sroll2"><%=classd.getSroll2() %></td>
<td><%=classd.getMarks2() %></td></tr>
<tr id="classrow3" style='display:none'>
<td></td>
<td></td>
<td><%=classd.getCsdate() %> (<%=classd.getCid() %>)</td>
<td><%=classd.getSname3() %></td>
<td id="sroll3"><%=classd.getSroll3() %></td>
<td><%=classd.getMarks3() %></td></tr></table>
<%
}
%>
</body></html>
But I didn't get the desired result. Please help. I know this is easy, but I'm new in this subject.