How to build a table layout

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • CD

    How to build a table layout

    I would like some guidance as to how to proceed to build a webpage in asp or
    aspx. I am going to hit a SQL db needing to get the following data:

    SELECT ServerName,Prim aryTech FROM tblservers GROUP BY
    PrimaryTech,Ser verName

    The idea is to display the data in a table format where the Column header
    would the PrimaryTech and under each tech would the ServerName they are
    responsible for.

    ie.....
    John Matt Joe
    Srv1 Srv3 Srv2
    Srv4 Srv6 Srv14

    TIA
    CD


  • Ray Costanzo [MVP]

    #2
    Re: How to build a table layout

    You'll wind up with data like:

    John Srv1
    Joe Srv14
    Joe Srv2
    Matt Srv3
    John Srv4
    Matt Srv6


    Throw in an order by clause, ORDER BY PrimaryTech,Ser verName so you have
    data like:

    Joe Srv14
    Joe Srv2
    John Srv1
    John Srv4
    Matt Srv3
    Matt Srv6

    Unfortunately, when you write out tables in HTML, your only option is to go
    left to right, and top to bottom. You can't do columns at a time. So, then
    the question becomes an HTML design issue. If you want to keep this all in
    one query, as opposed to executing a query for each person, you could do
    something like:



    <table border="1">
    <tr>
    <%

    Dim sOldname, sCurrentname
    sOldname = ""

    Do while not yourRecordset.E OF
    sCurrentname = yourRecordset.F ields.Item("Pri maryTech").Valu e
    If sCurrentname <> sOldname Then Response.Write "<td>"
    Response.Write yourRecordset.F ields.Item("Ser verName").Value & "<br>"
    sCurrentname = yourRecordset.F ields.Item("Pri maryTech").Valu e
    If sCurrentname <> sOldname Then
    Response.Write "<td>"
    Response.Write sCurrentname & "<br>"
    End If
    Response.Write yourRecordset.F ields.Item("Ser verName").Value & "<br>" &
    vbCrLf

    yourRecordset.M oveNext
    sOldname = sCurrentname
    sCurrentname = yourRecordset.F ields.Item("Pri maryTech").Valu e
    If sCurrentname <> sOldname Then Response.WRite "</td>"
    Loop
    %>
    </tr>
    </table>



    Ray at work




    "CD" <mcdye1@hotmail .REMOVETHIS.com > wrote in message
    news:eDJtg3B1FH A.3300@TK2MSFTN GP15.phx.gbl...[color=blue]
    >I would like some guidance as to how to proceed to build a webpage in asp
    >or aspx. I am going to hit a SQL db needing to get the following data:
    >
    > SELECT ServerName,Prim aryTech FROM tblservers GROUP BY
    > PrimaryTech,Ser verName
    >
    > The idea is to display the data in a table format where the Column header
    > would the PrimaryTech and under each tech would the ServerName they are
    > responsible for.
    >
    > ie.....
    > John Matt Joe
    > Srv1 Srv3 Srv2
    > Srv4 Srv6 Srv14
    >
    > TIA
    > CD
    >[/color]


    Comment

    Working...