Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Display each results from database in their own row

 
Annemarie McKeown
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have the following code implemented which connects to my database and retrieves data corresponding to my query using a while loop in ResultSet.
I have printed the output in a table although, all records are printed in the same row, after one complete record has been read, I want to place a carriage return and display the next row after the first, how to I stop all the records from displayin in one complete row across my browser.
JSP Code
--------
...
...
ResultSet rs = stmt.executeQuery("SELECT * from fileuploads where project_cat='"+category+"' && project_subject='english' && project_type='course_notes'");

if (rs != null)
{
while(rs.next())
{
String projectid = rs.getString("projectid");
String project_title= rs.getString("project_title");
String project_type = rs.getString("project_type");
String project_cat = rs.getString("project_cat");
String project_subject = rs.getString("project_subject");
String url_path = rs.getString("url_path");
%>
<table>
<tr><td><%=projectid%></td>
<td><%=project_title%></td>
<td><%=project_type%></td>
<td><%=project_cat%></td>
<td><%=project_subject%></td>
<td><a href="<%=url_path%>">Download</a></td></tr></table>
It will print something like:
1 Title1 Type1 Cat1 Subject1 Download 2 Title2 Type2.

and so I...I want to it to return to a new row when a new row is being read in the database.
Let me know if you can help, please. Probably something really simple, just cant figure out how to implement a loop of some sort.
 
leo donahue
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Annemarie,
Your question looks almost identical to a project I had in school. So, since you have already done most of the legwork, I'm just going to show you how I did mine. As I recall, we used a sample mdb file that was included wiht MS Access.

Grrr! Instant Graemlins!
[ March 04, 2004: Message edited by: leo donahue ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic