Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

HTML - dynamic tables, col1 ,row1, col1, row2, col1, row3...

Thread Tools
 
Search this Thread
 
Old 17 July 2002, 12:05 AM
  #1  
DazV
Scooby Regular
Thread Starter
 
DazV's Avatar
 
Join Date: Jun 2000
Posts: 3,783
Likes: 0
Received 0 Likes on 0 Posts
Post

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]
Old 17 July 2002, 10:48 AM
  #2  
SJ_Skyline
Scooby Senior
 
SJ_Skyline's Avatar
 
Join Date: Apr 2002
Location: Limbo
Posts: 21,922
Likes: 0
Received 1 Like on 1 Post
Question

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]
Old 17 July 2002, 12:41 PM
  #3  
DazV
Scooby Regular
Thread Starter
 
DazV's Avatar
 
Join Date: Jun 2000
Posts: 3,783
Likes: 0
Received 0 Likes on 0 Posts
Post

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
Old 17 July 2002, 01:54 PM
  #4  
SJ_Skyline
Scooby Senior
 
SJ_Skyline's Avatar
 
Join Date: Apr 2002
Location: Limbo
Posts: 21,922
Likes: 0
Received 1 Like on 1 Post
Exclamation

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>
Old 17 July 2002, 04:56 PM
  #5  
DazV
Scooby Regular
Thread Starter
 
DazV's Avatar
 
Join Date: Jun 2000
Posts: 3,783
Likes: 0
Received 0 Likes on 0 Posts
Post

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]
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
shorty87
Full Cars Breaking For Spares
19
22 December 2015 11:59 AM
buckerz69
Subaru Parts
7
08 October 2015 07:51 PM
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
shorty87
Other Marques
0
25 September 2015 08:52 PM



Quick Reply: HTML - dynamic tables, col1 ,row1, col1, row2, col1, row3...



All times are GMT +1. The time now is 04:03 AM.