Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

populating an HTML table from a database

Status
Not open for further replies.

JohannIcon

Programmer
Sep 3, 2002
440
MT
Hi All,

I am trying to populate an HTML table from a database, which I am managing, however, I am displaying the records all horizontally, and since I have a lot of records and images, the page looks very big. So I wish to display for example 8 records vertically and then another eight records vertically below them etc. How can I do that? Here is my existing code:-

<table width=&quot;80%&quot; height=&quot;100%&quot; border=&quot;1&quot; align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; bordercolor=&quot;#000000&quot;>
<%
rs.MoveFirst
%>
<tr>
<%do%>
<td width=&quot;33%&quot;><div align=&quot;center&quot;><br>
<a href=&quot;kunsilli.asp?cid=<%Response.Write(rs.Fields(&quot;CouncilID&quot;))%>&quot; target=&quot;_self&quot;><img src=&quot;images/flags/<%=(rs.Fields.Item(&quot;Image&quot;).Value)%>&quot; border=&quot;0&quot;></a>
</div></td>
<td width=&quot;67%&quot; class=&quot;LargeText&quot;><blockquote><b>
<%Response.Write(rs.Fields(&quot;CouncilName&quot;))%></b>
</blockquote></td>
</tr>
<%
rs.MoveNext
if rs.eof then
exit do
End If
loop until rs.eof
%>
</table>
 
Is it something like this that you want

<table width=&quot;80%&quot; height=&quot;100%&quot; border=&quot;1&quot; align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; bordercolor=&quot;#000000&quot;>
<%
rs.MoveFirst
Do While Not Rs.Eof
%>
<tr>
<%
For counter= 1 to 8
%>
<td width=&quot;33%&quot;><div align=&quot;center&quot;>
<a href=&quot;kunsilli.asp?cid=<%Response.Write(rs.Fields(&quot;CouncilID&quot;))%>&quot; target=&quot;_self&quot;><img src=&quot;images/flags/<%=(rs.Fields.Item(&quot;Image&quot;).Value)%>&quot; border=&quot;0&quot;></a>
</div></td>
<td width=&quot;67%&quot; class=&quot;LargeText&quot;><blockquote><b><%Response.Write(rs.Fields(&quot;CouncilName&quot;))%></b></blockquote></td>
<%
rs.MoveNext
Next
%>
</tr>
<%
loop
%>
</table> Saturday 12.00
im6.gif
im2.gif
im2.gif
20.00
im5.gif
im4.gif
im7.gif
3.00am
im8.gif
Sunday [img http
 
try the below:

<% dim i %>

<table width=&quot;80%&quot; height=&quot;100%&quot; border=&quot;1&quot; align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; bordercolor=&quot;#000000&quot;>
<%
rs.MoveFirst
%>

<%do%>
response.write &quot;<TR>&quot; 'write new row out

for i=0 to 7 'write out the 8 records

<td width=&quot;33%&quot;><div align=&quot;center&quot;><br>
<a href=&quot;kunsilli.asp?cid=<%Response.Write(rs.Fields(&quot;CouncilID&quot;))%>&quot; target=&quot;_self&quot;><img src=&quot;images/flags/<%=(rs.Fields.Item(&quot;Image&quot;).Value)%>&quot; border=&quot;0&quot;></a>
</div></td>
<td width=&quot;67%&quot; class=&quot;LargeText&quot;><blockquote><b>
<%Response.Write(rs.Fields(&quot;CouncilName&quot;))%></b>
</blockquote></td>
<%
rs.MoveNext

if rs.eof then exit for

next

response.write &quot;</TR>&quot; 'close row

if rs.eof then exit do

loop until rs.eof
&quot;did you just say Minkey?, yes that's what I said.&quot;

MrGreed
 
In the meantime, I found this which is very simple and really works!

<table width=&quot;11%&quot; height=&quot;100%&quot; border=&quot;0&quot; cellpadding=&quot;1&quot; cellspacing=&quot;3&quot; bordercolor=&quot;#000000&quot;>
<%
rs.MoveFirst
%>
<tr>
<% count=0
do while not rs.EOF
count=count+1%>
<td height=&quot;42&quot;> <a href=&quot;kunsilli.asp?cid=<%Response.Write(rs.Fields(&quot;CouncilID&quot;))%>&quot; target=&quot;_self&quot;><img src=&quot;images/flags/<%=(rs.Fields.Item(&quot;Image&quot;).Value)%>&quot; border=&quot;0&quot; align=&quot;middle&quot;></a>
<%Response.Write(rs.Fields(&quot;CouncilName&quot;))%></b>
<%linecheck=count MOD 5
if linecheck=0 then
Response.Write(&quot;</td></tr><tr>&quot;)
end if
rs.Movenext
loop%>
</table>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top