• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Creating a HTML table to display values from a database

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a database where I need to display as many rows in a HTML table as the maximum value in one of the columns in the corresponding table in a database.

For example, consider this bunch of data stored in the database:

1 | 1 | abc
1 | 2 | def
1 | 3 | ghi
2 | 1 | jkl
2 | 2 | mno
2 | 3 | pqr

Now, I need to create two rows (because the maximum value in the first column is 2) in the HTML table where I want to display this data. However, for every row which has the value 1 or 2, I need to create three columns (because there are three entries with the values 1 and 2 in the first column).

So the result (i.e. HTML table) rendered on the JSP page should be something like (consider that I'm displaying the last column):

abc | def | ghi
jkl | mno | pqr


How do I implement this in JSP, considering that I'm following an MVC architecture (no special frameworks like Struts and the like though)?

Thanks all for your inputs.

[ January 08, 2008: Message edited by: Sridhar Venkataraman ]

[ January 08, 2008: Message edited by: David O'Meara ]
[ January 08, 2008: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Considering this is your database table:-

1 | 1 | abc
1 | 2 | def
1 | 3 | ghi
2 | 1 | jkl
2 | 2 | mno
2 | 3 | pqr

Could you please mention/draw here the layout to be displayed in web page (2rows & 3 columns with above data) also? Because I am not sure what you want to be displayed exactly.
 
Sridhar Venkataraman
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So the result (i.e. HTML table) rendered on the JSP page should be something like (consider that I'm displaying the last column):

abc | def | ghi
jkl | mno | pqr

Here...I had this in my first post.

Basically this comes from the fact that the first column has two distinct numnbers (1 and 2), and there are three instances where these numbers appear in the first column. So I need the output to display all the rows which have a value of 1,2....and so on in the same row on the HTML table.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please EaseUp.

Dave
 
Sridhar Venkataraman
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apologies...it's kind of a bad habit that I have
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No problem
 
Stinging nettles are edible. But I really want to see you try to eat this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic