Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
ash neet
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • 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!

 
Swastik Dey
Rancher
Posts: 1601
5
Android Java Java ME
  • 0
  • Mark post as helpful
  • send pies
  • 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>
 
Malatesh Karabisti
Ranch Hand
Posts: 153
Java Oracle
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey thanks Swastik, it worked.
 
ash neet
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
sri ramvaithiyanathan
Ranch Hand
Posts: 109
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Sri. Sure, will tell you

Regards,

Ash.
 
Swastik Dey
Rancher
Posts: 1601
5
Android Java Java ME
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic