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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic database info into html table

Status
Not open for further replies.

meldrape

Programmer
May 12, 2001
516
US
I have 182 records in a table and instead of listing them in one long line, I have the following code that puts them in three columns. My problem is that the third column always has a blank as the first record. I don't know why, and there are no blanks in my database table. If anybody has any idea, I'd appreciate the input. Thanks.

<!--Database info-->
<%
Set oRs = objConn.Execute(&quot;SELECT * FROM newsletters order by friendly_name;&quot;)
%>

<%
response.write &quot;<table><tr>&quot;

count = 1
do while not ors.eof
if count mod 3 = 0 then
'there are 3 in the current row, so end the row and start a new one...
response.write &quot;</tr><tr>&quot;
end if

'add the cat name to another column
response.write &quot;<td valign=top>&quot; & oRS(&quot;friendly_name&quot;) & &quot;</td>&quot;

'increment the count
count = count+1

oRS.MoveNext
loop

oRs.Close
objConn.Close

Set oRs = Nothing
Set objConn = Nothing
%>
 
your first record, count=1, count mod 3 = 1, so it starts the first column.
second record, count=2, count mod 3 = 2, so it starts the second column.
third record, count=3, count mod 3 = 0, so it ends that row, starts the new row in column 1.
fourth record, count mod 3 = 1, puts it in column 2.
fifth record, count mod 3 = 2, puts it in column 3.
sixth record, count mod 3 = 0, end row, start new row.
etc., etc., etc.

i would start with count = 0 and check for that before the mod 3, a special condition for count = 0, starting the row and the first column, then continue.... if you need more specifics, let me know.
 
Well, blow me down. I thought I had already tried that, but I guess I didn't. Thanks a million. It works!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top