Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

jsp table

Status
Not open for further replies.

anvi123

Programmer
Mar 27, 2008
3
With the below code I am getting the output as below.I am getting data from database as shown in the code

Displaying All Users

FirstName LastName UserName Password
Ann go ago VVVV
ffff ffff ffff ffffff
sag rag tom kim
gen man rfff kkk
fff jjj hhh hhh


...so on.

But I have to display as shown below. Is it possible or Not. if it possible, How would show that, Please let me know ASAP

FirstName aaaa aaaa anna ggg henn ffff hhh jjj kkk llll oooo pppp mmmm jjjjj kkkkkkk llllllll gggg qqqqq
LastName ssss ffff ggg hhh nnn kkk lll bbb vvvv ssss aaaa qqqq w ssss aaaa zzzz bbbb nnnnn
UserName ....so on
Password


<%@ page session ="false"%>
<%@ page import ="java.sql.*"%>
<%

try{
Class.forName(("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("JDBC driver loaded");
}catch(ClassNotFoundException e){
System.out.println(e.toString());
}
%>
<HTML>
<HEAD>
<TITLE> Display ALL Users<TITLE>
</HEAD>
<Body>
<BR><H2>Displaying ALL Users</H2>
<BR>
<BR>
<TABLE>
<TR>
<TH> First Name </TH>
<TH> Last Name </TH>
<TH> User Name </TH>
<TH> Password</TH>
</TR>
<%
String sql = "select firstname, lastname, username, password" +"from Users";
try{
Connection con = DriverManager.getConnection("jdbc:eek:dbc:JavaWeb");
Statement s = con.createStatement();
ResultSet rs = s.executeQuery(sql);
while(rs.next()) {
%>
<tr>
<td><% out.print(rs.getString(1); %></TD>
<td><% out.print(rs.getString(2); %></TD>
<td><% out.print(rs.getString(3);%></TD>
<td> <% out.priint(rs.getString(4));%></TF>
</tr>
<%
}
rs.close();
s.close();
con.close();
}
cath(SqlException e) {
}
catch(Exception e) {
}
%>
</Table>
</center>
</body>
</html>


Thanks a lot.
 
if you don't mind tables inside of tables inside of tables....

Code:
<td>
<table><tr><td>
<% out.print(rs.getString(1); %></TD></tr><tr>
<td><% out.print(rs.getString(2); %></TD></tr><tr>
<td><% out.print(rs.getString(3);%></TD></tr><tr>
<td> <% out.priint(rs.getString(4));%></td></tr></table></td>
 
Thanks for your reply.

What changes do I have to make for the below code? If the ouput should be like below.

FirstName aaaa aaaa anna ggg henn ffff hhh jjj kkk llll oooo pppp mmmm jjjjj kkkkkkk llllllll gggg qqqqq
LastName ssss ffff ggg hhh nnn kkk lll bbb vvvv ssss aaaa qqqq w ssss aaaa zzzz bbbb nnnnn
UserName ....so on
Password

Here is my code, I don't understand here where exactly I can make changes what you said before for the below format. Can you please help me

*if* (rs.getRow() > 0)
{

sResult = sResult.concat( "<tr BGCOLOR=#99CCFF>"); sResult = sResult.concat( "<td valign= bottom><font size="2">" + "HITS" + "</font></td>" );
sResult = sResult.concat( "<tr> <td valign=bottom> <font size="2">" + "REISSUED" + "</font></td></tr>" );
sResult = sResult.concat( "<tr> <td valign= bottom> <font size="2">" + "ADD_COLL" + "</font></td></tr>" );
sResult = sResult.concat( "<tr> <td valign= bottom> <font size="2">" + "CHANGE_FEE" + "</font></td></tr>" );
sResult = sResult.concat( "<tr> <td valign= bottom> <font size="2">" + "AMT_PROCESSED" + "</font></td></tr>" );
sResult = sResult.concat( "<tr> <td valign= bottom><font size="2">" + "Est_AMT" + "</font></td></tr></tr>" );

*do*
{
sAmount1 = dfAmount1.format(rs.getInt(1));
sAmount2 = dfAmount1.format(rs.getInt(2));
sAmount3 = dfAmount2.format(rs.getDouble(3));
sAmount4 = dfAmount2.format(rs.getDouble(4));
sAmount5 = dfAmount2.format(rs.getDouble(5));
sAmount6 = dfAmount2.format(rs.getDouble(6));


sResult = sResult.concat("<td align= right>" + sAmount1 + "</td>");
sResult = sResult.concat("<td align=right>" + sAmount2 + "</td></tr>");
sResult = sResult.concat("<td align=right>" + sAmount3 + "</td></tr>");
sResult = sResult.concat("<td align=right>" + sAmount4 + "</td></tr>");
sResult = sResult.concat("<td align=right>" + sAmount5 + "</td></tr>");
sResult = sResult.concat("<td align=right>" + sAmount6 + "</td></tr>");
}*while*(rs.next());



sResultTable = "<table>"
+ sResultTable
+"<p><b><font color="#3366FF" size="4">"
+ s[iC]
+ " " + "</font>"
+ "<br>"
+"</b>"
+"<table width=90% border=1 cellpadding=0 cellspacing=0 height=60>"
*+ sResult //* Here I am adding all the result
+ "</table>";

}
 
Could you please anyone help me in resolving this? I am not able to get the format. What changes do I have to make to the above code to get the below format?

hits 4444 55 66 777 888 999 00 77
reissued 666 888 999 000 666 7777


Thanks a lot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top