Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-12-2008, 09:40 AM
Member
 
Join Date: Feb 2008
Posts: 2
am17mu is on a distinguished road
<tr><td> arrangement in a method
Hi EveryOne,

I have this code, which is used to access, a table from the database (postgresql) and is used to display 5 attributes, with all data, in the following format

JudgeId Name Designation Address Active Status
1 *** *** *** ***
2 *** *** *** ***
.
.
. as follows

the code i have writen is as follows

Code:
String Qry= "SELECT \"JUDGEID\",\"NAME\",\"DESIGNATION\",\"ADDRESS\",\"ACTIVE_STATUS\" FROM \"Tax\".\"JUDGES\""; rset= stmt.executeQuery(Qry); while(rset.next()){ list.add(rset.getString(1)); list.add(rset.getString(2)); list.add(rset.getString(3)); list.add(rset.getString(4)); list.add(rset.getString(5)); } /*this for loop, works fine for 2 elements,but for 5 elements, as above it does not display properly. */ for(int i=0;i<list.size();i++){ if(i==0 || i%2==0){ list.set(i,"<tr><td align='center'>"+list.get(i)+"</td>"); }else{ list.set(i,"<td align='center'>"+list.get(i)+"</td></tr>"); } }
*******************************************
I know, the problem lies within the if code, something with the <tr><td>
But can't seem to make it work
Please help guys
Thanks in advance
am17mu
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-16-2008, 06:44 PM
ShoeNinja's Avatar
Senior Member
 
Join Date: Oct 2007
Posts: 112
ShoeNinja is on a distinguished road
Send a message via AIM to ShoeNinja
I think you're right. The problem is in your if condition.

Code:
for(int i=0;i<list.size();i++){ if(i==0 || i%2==0){ list.set(i,"<tr><td align='center'>"+list.get(i)+"</td>"); }else{ list.set(i,"<td align='center'>"+list.get(i)+"</td></tr>"); } }

I'm not sure why you open your <tr> element when the if is true and close if when it is not.

I think there are some better ways to accomplish what you are going for but it's hard to tell without seeing more code.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot call private method from static method jon80 New To Java 3 05-07-2008 09:37 AM
Method Help pringle New To Java 4 04-16-2008 02:23 PM
method not abstract, does not override actionperformed method. Theman New To Java 1 05-08-2007 07:13 AM


All times are GMT +3. The time now is 11:02 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org