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!

Table Headers on Left (instead of top) 1

Status
Not open for further replies.

stein555

Programmer
Apr 18, 2003
24
US
How do you do this? I remember seeing a thread a month or two ago about this, but I didn't read it. Now I am needing to do this myself. Is there a quick CSS trick that can do this?

Basically I want all the headers to be listed vertically down the page and the data "underneath" them to be listed out to the right.

Thank you for your help...
Stein
 
I saw that thread. Am I missing something? What I see in that thread is how to rotate the text to display vertically inside the table (which isn't what I need).

I do see the example in there where the person is flipping the text using CSS (filter:flipv fliph), but all that does is put my column headers on the bottom - I need them on the left.

Please tell me if I am missing something, though, because I am stumped!

Thanks!
 
Erm... you want to build a table where the left-most column is the headings and the other columns is the data? Then just write it that way!

[tt]<table>
<tr>
<th>Heading 1</th>
<td>Data 1</td>
<td>Data 2</td>
<td>Data 3</td>
</tr>
<tr>
<th>Heading 2</th>
<td>Data 4</td>
<td>Data 5</td>
<td>Data 6</td>
</tr>
</table>[/tt]

You can use the CSS from the other thread to turn the text around in each cell if you want/need to.

-- Chris Hunt
Extra Connections Ltd
 
I would love to, but I'm pulling all the data for the table from a database...I will post my code to queue you in more on what I am doing...

<table border=1 width=100%>
<tr>
<%
k = i
do while NOT rsDB.Fields.Item(k).Name = request.querystring(&quot;end&quot;)
response.write(&quot;<td align=center><b>&quot; & rsDB.Fields.Item(k).Name & &quot;</b></td>&quot;)
k = k + 1
loop

k = k - 1
do while NOT rsDB.EOF%>
<tr>
<%
for j = i to k
response.write(&quot;<td>&quot; & rsDB.Fields.Item(j).Value & &quot;</td>&quot;)
next
rsDB.MoveNext
loop
%>
</tr>
</table>

Basically, the table is created dynamically depending on what database the user chooses to open. But I need the headers from the database to be on the left side (instead of the top). When I use the flip mode, it just turns everything over, but doesn't rotate it.
 
Just to make things a lil bit clearer for everybody
Normally you would have an output like .
A B C
1 10 100
2 20 200
3 30 300

and what you need is to &quot;Transpose&quot; the whole table to

A 1 2 3
B 10 20 30
C 100 200 300


PLease let me know if I understood correctly.

grtfercho çB^]\..
&quot;Imagination is more important than Knowledge&quot; A. Einstein
 
Exactly! Thank you, grtfercho, for clearing that up ;)
 
Try this. I don't have ASP installed here but the logic should work.
Because you would need an algorithm to go jumping from 1 to 10 an then to 100 for every row it will be difficult to acomplish that in just one table.
That's why I created a new table for each new column.
You'll end up with more code on the page but it should work.
Intersting question. let us know if it worked or not.


<table border=1 width=100%>
<tr>
<td><table>
<%
k = i
do while NOT rsDB.Fields.Item(k).Name = request.querystring(&quot;end&quot;)
response.write(&quot;<tr><th align=center><b>&quot; & rsDB.Fields.Item(k).Name & &quot;</b></th></tr>&quot;)
k = k + 1
loop
%>
</table>
</td>
<%
k = k - 1
do while NOT rsDB.EOF%>
<td><table>
<%
for j = i to k
response.write(&quot;<tr><td>&quot; & rsDB.Fields.Item(j).Value & &quot;</td></tr>&quot;)
next
rsDB.MoveNext
%>
</table>
</td>
<%
loop
%>
</tr>
</table>


grtfercho çB^]\..
&quot;Imagination is more important than Knowledge&quot; A. Einstein
 
Almost! Except it doesn't separate out each entry as a separate table element. So it crams all the headers together on the left, and all the data together on the right (and they aren't one line a piece).

Good idea, though...I may play around with the logic on that one to see if I can figure it out too...
 
Aight...I figured it out...thank you for the help grtfercho!

Here's the code...

<table border=1 width=100%>
<%
k = i
do while NOT rsDB.Fields.Item(k).Name = request.querystring(&quot;end&quot;)
response.write(&quot;<tr><th>&quot; & rsDB.Fields.Item(k).Name & &quot;</th>&quot;)
rsDB.MoveFirst
do while NOT rsDB.EOF
response.write(&quot;<td>&quot; & rsDB.Fields.Item(k).Value & &quot;</td>&quot;)
rsDB.MoveNext
loop
response.write(&quot;</tr>&quot;)
k = k + 1
loop
%>
</table>

=)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top