• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Add row dynamically in html table based on the number of records in the database using jsp

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Everyone,

i have a table in the html page. i want to display images in the table cells. the images will come from the database using the links stored in the database. i am using <img src="<%=image_link%>"> for displaying the images. but the problem is i want to display only 4 images in each row. while getting the values from database using while loop, if there are more than 4 images, it should dynamically create a new row. I don't know how to do it. Please help!

 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<table>
while(!end of recordstore){
<tr>
for(a loop that itreates 4 times){
<td>your field value</td>
}
</tr>
}
</table>
 
Ranch Hand
Posts: 153
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ash,

what you are using JSP or HTML ?
in JSP you can add the rows dynamcally I think you know the basic difference between JSP & HTML.
 
ash neet
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey thanks Swastik, it worked.
 
ash neet
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Malatesh Karabisti wrote:ash,

what you are using JSP or HTML ?
in JSP you can add the rows dynamcally I think you know the basic difference between JSP & HTML.



I am using JSP. that's why I asked how to create table rows dynamically.
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ash,

you want to display four images per row.so create a four <div> <img src tag> </div>or <table> <img src tag></table>
in your jsp.
Iterate the loop for 4times and give <br>
Then only your images will display in proper alignment.

Swastik Dey idea will work but the image will not display in proper alignment.
Check thisGetty Images link.
right click on the page and check the source by clicking view source.
For more information check all images website even google image.
you will come to know.

Regards,
Sriram.V
 
ash neet
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sri ramvaithiyanathan wrote:Hi Ash,

you want to display four images per row.so create a four <div> <img src tag> </div>or <table> <img src tag></table>
in your jsp.
Iterate the loop for 4times and give <br>
Then only your images will display in proper alignment.

Swastik Dey idea will work but the image will not display in proper alignment.
Check thisGetty Images link.
right click on the page and check the source by clicking view source.
For more information check all images website even google image.
you will come to know.

Regards,
Sriram.V




Hi Sriram,

Yes, alignment is a problem. everytime i display the images, they get displayed in different ways everytime.

thank you very much. i will try your idea.

Regards,

Ash
 
sri ramvaithiyanathan
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Happy to help.
if you have any doubt kindly let us know.

Regards,
Sriram.V
 
ash neet
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Sri. Sure, will tell you

Regards,

Ash.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With table tag itself you can have proper alignments. I just hinted how to proceed with the logic.

http://www.eobcards.com/tables102.htm
 
Don't count your weasels before they've popped. And now for a mulberry bush related tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic