473,473 Members | 1,824 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Generate a table with ASP

Hi!

I need to create a table with 4 cols and X rows based on the number records
in my database. I dont know how this can be done, mabye with an array?

If I got for example 6 records in my database, a table with 4 cols and 2
rows should be generated, the last row will only have 2 cols with
information...

Like this:

<table>
<tr>
<td>Record1</td>
<td>Record2</td>
<td>Record3</td>
<td>Record4</td>
</tr>
<tr>
<td>Record5</td>
<td>Record6</td>
<td></td>
<td></td>
</tr>
</table>

-----------------------------------

This is what I have made so far:
<table>
<%
set rsArt= server.CreateObject("adodb.recordset")
rsArt.Open SQL,conn

do until rsArt.EOF

rsArt.MoveNext
loop

rsArt.Close
set rsArt = nothing
%>
</table>

-----------------------------------
Can someone please help me with this one???

Regards,
Øyvind Isaksen
Jul 22 '05 #1
4 1406
X=1
....loop start.....
X=X+1
if x=4 then
...</tr><tr>...
....X=1
End if
....loop end...

You get the idea...

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Øyvind Isaksen" <oy****@webressurs.no> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl...
Hi!

I need to create a table with 4 cols and X rows based on the number
records in my database. I dont know how this can be done, mabye with an
array?

If I got for example 6 records in my database, a table with 4 cols and 2
rows should be generated, the last row will only have 2 cols with
information...

Like this:

<table>
<tr>
<td>Record1</td>
<td>Record2</td>
<td>Record3</td>
<td>Record4</td>
</tr>
<tr>
<td>Record5</td>
<td>Record6</td>
<td></td>
<td></td>
</tr>
</table>

-----------------------------------

This is what I have made so far:
<table>
<%
set rsArt= server.CreateObject("adodb.recordset")
rsArt.Open SQL,conn

do until rsArt.EOF

rsArt.MoveNext
loop

rsArt.Close
set rsArt = nothing
%>
</table>

-----------------------------------
Can someone please help me with this one???

Regards,
Øyvind Isaksen

Jul 22 '05 #2
So, your recordset just has one column being returned? How about something
like:
<table>
<%
Const COLUMNS = 4
Dim i : i = 0

Do While Not rs.EOF
If i Mod COLUMNS = 0 Then Response.Write " <tr>" & vbCrLf
Response.Write " <td>" & rs(0) & "</td>" & vbCrLf
If i Mod COLUMNS = COLUMNS - 1 Then Response.Write " </tr>" & vbCrLf
i = i + 1
rs.MoveNext
Loop

''fill in some empty tds with &nbsp; if needed
If i Mod COLUMNS <> 0 Then
For j = 1 To COLUMNS - (i Mod COLUMNS)
Response.Write " <td>&nbsp;</td>" & vbCrLf
Next
Response.Write " </tr>"
End If
%>
</table>

Ray at work

"Øyvind Isaksen" <oy****@webressurs.no> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl...
Hi!

I need to create a table with 4 cols and X rows based on the number records in my database. I dont know how this can be done, mabye with an array?

If I got for example 6 records in my database, a table with 4 cols and 2
rows should be generated, the last row will only have 2 cols with
information...

Like this:

<table>
<tr>
<td>Record1</td>
<td>Record2</td>
<td>Record3</td>
<td>Record4</td>
</tr>
<tr>
<td>Record5</td>
<td>Record6</td>
<td></td>
<td></td>
</tr>
</table>

-----------------------------------

This is what I have made so far:
<table>
<%
set rsArt= server.CreateObject("adodb.recordset")
rsArt.Open SQL,conn

do until rsArt.EOF

rsArt.MoveNext
loop

rsArt.Close
set rsArt = nothing
%>
</table>

-----------------------------------
Can someone please help me with this one???

Regards,
Øyvind Isaksen

Jul 22 '05 #3
"Øyvind Isaksen" <oy****@webressurs.no> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl...
If I got for example 6 records in my database, a table with 4 cols
and 2 rows should be generated, the last row will only have 2 cols
with information...


Something like this?

Do While Not rsArt.EOF
RW "<tr>"
For iCol = 1 To 4
If Not rsArt.EOF Then
RW "<td>" & celldata & "</td>"
rsArt.MoveNext
Else
' Empty cell after all the data
RW "<td></td>"
End If
Next
RW "</tr>"
Loop

HTH,
Phill W.
Jul 22 '05 #4
"Øyvind Isaksen" <oy****@webressurs.no> wrote in message
news:#N**************@TK2MSFTNGP12.phx.gbl...
Hi!

I need to create a table with 4 cols and X rows based on the number records in my database. I dont know how this can be done, mabye with an array?

If I got for example 6 records in my database, a table with 4 cols and 2
rows should be generated, the last row will only have 2 cols with
information...

Like this:

<table>
<tr>
<td>Record1</td>
<td>Record2</td>
<td>Record3</td>
<td>Record4</td>
</tr>
<tr>
<td>Record5</td>
<td>Record6</td>
<td></td>
<td></td>
</tr>
</table>

-----------------------------------

This is what I have made so far:
<table>
<%
set rsArt= server.CreateObject("adodb.recordset")
rsArt.Open SQL,conn

do until rsArt.EOF

rsArt.MoveNext
loop

rsArt.Close
set rsArt = nothing
%>
</table>

-----------------------------------
Can someone please help me with this one???

Regards,
Øyvind Isaksen


Will this help?
<table>
<tr>
<%
const rows = 4
dim i, j
i = 0
j = 0
set rsArt= server.CreateObject("adodb.recordset")
rsArt.Open SQL,conn
do until rsArt.EOF
i = i + 1
if i > 1 and i Mod rows = 1 then
j = 0
%>
</tr>
<tr>
<% end if %>
<td><%=rsArt("field_name")%></td>
<%
j = j + 1
rsArt.MoveNext
loop
rsArt.Close
set rsArt = nothing

for i = 1 to rows - j
%>
<td>&nbsp;</td>
<%
next
%>
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Terri | last post by:
I'd I have a problem I'd like to post CREATE TABLE and INSERT statements that will create my table and insert data into the table. I can use the scripting feature in Enterprise Manager to...
1
by: muesliflakes | last post by:
I'm trying to generate a normalized XML document out of SQL server that reflects the data structure of a table. Eg. This is what I would like to get <table name='MtFeedback'> <field...
6
by: Sebastien | last post by:
Hi, I am building a products database, linking sales and production. Each part has a unique sales Stock Code and Production Number. The sales stock code is a combination of letters and numbers...
2
by: Keith A. Rowe | last post by:
I have developed apps on scores of platforms for 25 years. Each of these platforms have supported a "quick, but not so dirty" utility for code table maintenance. For example, I have a States...
1
by: ASP.Net programmer | last post by:
I have a few SQLDataAdapters which select a MAX() value from a few different tables. Here is a sample of the SQL statement: SELECT MAX(startdate) AS startdate FROM some_table1 WHERE (startdate...
5
by: pete | last post by:
Help, I can not find this data wizard in my toolbox under data. To generate a dataset 1.. From the Data menu, choose Generate DataSet. Tip If you do not see the Data menu, click in the...
5
by: Hunter Hillegas | last post by:
I have a CSV file with 400,000 lines of email mailing list information that I need to migrate to a new PostgreSQL database. Each line has all the info I need except a PK (I usually use an int4...
0
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional...
15
by: Orchid | last post by:
Hello, I am looking to generate a unique ID field on MS. Access. The ID is with 10 digits with the combination of 5 Letters from the 26 letters and 5 Numbers from 1 to 9. The letters and numbers...
11
by: Alan Mailer | last post by:
A project I'm working on is going to use VB6 as a front end. The back end is going to be pre-existing MS Access 2002 database tables which already have records in them *but do not have any...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.