HTML - dynamic tables, col1 ,row1, col1, row2, col1, row3...
#1
Is there anyway in HTML to create a dynamic table and fill it with rows from a database, like this
col1......|col2......
db_row1|db_row4
db_row2|db_row5
db_row3|db_row6
I know I can do it in 2 steps first filling a 2D array with rows from the database, then creating the table that way
I was wondering if there's any commands in HTML that will allow me to create the table in one shot as shown above ?
-DV
[Edited by DazV - 7/17/2002 12:07:45 AM]
col1......|col2......
db_row1|db_row4
db_row2|db_row5
db_row3|db_row6
I know I can do it in 2 steps first filling a 2D array with rows from the database, then creating the table that way
I was wondering if there's any commands in HTML that will allow me to create the table in one shot as shown above ?
-DV
[Edited by DazV - 7/17/2002 12:07:45 AM]
#2
What server side scripting are you using to pull out the data?
I would consider opening two recordsets and moving halfway through the second at the start of the table:
Col1 -- Col2
rs1.val1 -- rs2.val1
rs1.val2 -- rs2.val2
rs1.val3 -- rs2.val3
where rs2.val1 = rs1.val4
[Edited by SJ_Skyline - 7/17/2002 10:53:25 AM]
I would consider opening two recordsets and moving halfway through the second at the start of the table:
Col1 -- Col2
rs1.val1 -- rs2.val1
rs1.val2 -- rs2.val2
rs1.val3 -- rs2.val3
where rs2.val1 = rs1.val4
[Edited by SJ_Skyline - 7/17/2002 10:53:25 AM]
#3
SJ, COLDFUSION
1)Thought about pulling all the data into a 2D array then filling the table that way.
2)Alternatively your way, where you'd open 3 queries if you had 3 columns:
Assuming the table has a column height of 10 rows, open 1st query with rows 0-9, 2nd query 10-19, 3rd 20-29 ?
Which do you think is the most resource (memory/cpu) friendly method?
Thanks again mate,
-DV
1)Thought about pulling all the data into a 2D array then filling the table that way.
2)Alternatively your way, where you'd open 3 queries if you had 3 columns:
Assuming the table has a column height of 10 rows, open 1st query with rows 0-9, 2nd query 10-19, 3rd 20-29 ?
Which do you think is the most resource (memory/cpu) friendly method?
Thanks again mate,
-DV
#4
Don't have access to a CF server to test this but this could well be a good way to go, it makes use of reading the data into a 1D array ....
<cfset counter = 1>
<cfset myarray = your data here>
<cfset arrlen = ArrayLen(myarray)>
<cfset maxcols = Int(arrlen / 10)>
<table>
<cfloop index="rows" from="1" to="10" step="1">
<tr>
<cfloop index="cols" from="1" to="maxcols" step="1">
<td>
<cfoutput>#myarray[counter]#</cfoutput>
</td>
<cfset counter = counter + 10>
</cfloop>
</tr>
<cfset counter = rows>
</cfloop>
</table>
<cfset counter = 1>
<cfset myarray = your data here>
<cfset arrlen = ArrayLen(myarray)>
<cfset maxcols = Int(arrlen / 10)>
<table>
<cfloop index="rows" from="1" to="10" step="1">
<tr>
<cfloop index="cols" from="1" to="maxcols" step="1">
<td>
<cfoutput>#myarray[counter]#</cfoutput>
</td>
<cfset counter = counter + 10>
</cfloop>
</tr>
<cfset counter = rows>
</cfloop>
</table>
#5
yep, I'm sure that would do it too.
Thanks
ps: A couple of adjustments to clean it up...
<table>
<cfloop index="rows" from="1" to="10" step="1">
<cfset counter = rows>
<tr>
<cfloop index="cols" from="1" to=#maxcols# step="1">
<td>
<cfoutput>#myarray[counter]#</cfoutput>
</td>
<cfset counter = counter + 10>
</cfloop>
</tr>
</cfloop>
</table>
[Edited by DazV - 7/17/2002 6:09:24 PM]
Thanks
ps: A couple of adjustments to clean it up...
<table>
<cfloop index="rows" from="1" to="10" step="1">
<cfset counter = rows>
<tr>
<cfloop index="cols" from="1" to=#maxcols# step="1">
<td>
<cfoutput>#myarray[counter]#</cfoutput>
</td>
<cfset counter = counter + 10>
</cfloop>
</tr>
</cfloop>
</table>
[Edited by DazV - 7/17/2002 6:09:24 PM]
Thread
Thread Starter
Forum
Replies
Last Post
shorty87
Full Cars Breaking For Spares
19
22 December 2015 11:59 AM
Pro-Line Motorsport
Car Parts For Sale
2
29 September 2015 07:36 PM
shorty87
Wheels And Tyres For Sale
0
29 September 2015 02:18 PM