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 record set

Status
Not open for further replies.

loganswell

Programmer
Dec 28, 2000
111
GB
Hi fellow ASP people,

Can anyone tell me how to code in ASP (VBScript) the correct way to populate an HTML table where the desired results are as follows:

{do loop}

<tr>
<td> record in here </td>
<td> record in here </td>
</tr>

{end loop}

I hope I've explained what I need well enough!

Thank you!

Jim
 
This is some stripped down code, so it may have a bit or two missing, but it looks right.

If you want to get really snazzy, you can make rows alternate silver and white background.

<table width=&quot;... etc>

<%
for rowcount = 0 to [number of items/number of columns - 1]
response.write &quot;<tr>&quot;
for columnCount = 1 to [number of columns]
response.write &quot;<td>&quot;

CellPointer = (rowcount * 3) + columnCount
'(Cellpointer can be used if you want to put something into a cell based on the cellcount)

%>
<td>

Some stuff from db

</td>
<%
NEXT
response.write &quot;</tr>&quot;
NEXT
%>
</table>



Steve Davis
hey.you@hahaha.com.au
 
I'm very grateful to you for your reply - I'll give it a whirl! :eek:)

Regards,

Jim
 
Although grateful to Steve Davis, unfortunately I was unable to slot his code into what I wanted. However since posting my request I think I have it sussed and would like to share the code with anyone who may be interested....

<table>
<tr>
<% count=0
DO WHILE NOT rsLinks.EOF
count=count+1%>
<td>
<%=rsLinks(&quot;field_1&quot;)%>&quot;><%=rsLinks(&quot;field_2&quot;)%>
<%linecheck=count MOD 2
if linecheck=0 then
Response.Write(&quot;</td></tr><tr>&quot;)
end if
rsLinks.Movenext
LOOP%>
</table>

Thanks,

Jim
 
Jim,

The code was just a basic skeleton that I had pulled out of one of my pages. I am not surprised that it didn't work straight away :)

However, I hope it did serve the purpose in getting you on the right track.
Steve Davis
hey.you@hahaha.com.au
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top