File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Add row dynamically in html table based on the number of records in the database using jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Add row dynamically in html table based on the number of records in the database using jsp" Watch "Add row dynamically in html table based on the number of records in the database using jsp" New topic
Author

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

ash neet
Ranch Hand

Joined: Dec 21, 2010
Posts: 33
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

Joined: Jan 08, 2009
Posts: 1477
    
    6

<table>
while(!end of recordstore){
<tr>
for(a loop that itreates 4 times){
<td>your field value</td>
}
</tr>
}
</table>


Swastik
Malatesh Karabisti
Ranch Hand

Joined: Jul 28, 2010
Posts: 153

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

Joined: Dec 21, 2010
Posts: 33
Hey thanks Swastik, it worked.
ash neet
Ranch Hand

Joined: Dec 21, 2010
Posts: 33
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

Joined: Nov 20, 2010
Posts: 109
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


For java examples,ebooks,interview questions,visit this blog
http://periodicupdates.blogspot.com/
ash neet
Ranch Hand

Joined: Dec 21, 2010
Posts: 33
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

Joined: Nov 20, 2010
Posts: 109
Happy to help.
if you have any doubt kindly let us know.

Regards,
Sriram.V
ash neet
Ranch Hand

Joined: Dec 21, 2010
Posts: 33
Thanks Sri. Sure, will tell you

Regards,

Ash.
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1477
    
    6

With table tag itself you can have proper alignments. I just hinted how to proceed with the logic.

http://www.eobcards.com/tables102.htm
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Add row dynamically in html table based on the number of records in the database using jsp