How to build a table layout

Discussion in 'ASP General' started by CD, Oct 18, 2005.

  1. CD

    CD Guest

    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,PrimaryTech FROM tblservers GROUP BY
    PrimaryTech,ServerName

    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
    CD, Oct 18, 2005
    #1
    1. Advertising

  2. 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,ServerName 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.EOF
    sCurrentname = yourRecordset.Fields.Item("PrimaryTech").Value
    If sCurrentname <> sOldname Then Response.Write "<td>"
    Response.Write yourRecordset.Fields.Item("ServerName").Value & "<br>"
    sCurrentname = yourRecordset.Fields.Item("PrimaryTech").Value
    If sCurrentname <> sOldname Then
    Response.Write "<td>"
    Response.Write sCurrentname & "<br>"
    End If
    Response.Write yourRecordset.Fields.Item("ServerName").Value & "<br>" &
    vbCrLf

    yourRecordset.MoveNext
    sOldname = sCurrentname
    sCurrentname = yourRecordset.Fields.Item("PrimaryTech").Value
    If sCurrentname <> sOldname Then Response.WRite "</td>"
    Loop
    %>
    </tr>
    </table>



    Ray at work




    "CD" <> wrote in message
    news:...
    >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,PrimaryTech FROM tblservers GROUP BY
    > PrimaryTech,ServerName
    >
    > 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], Oct 18, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric
    Replies:
    4
    Views:
    712
    clintonG
    Dec 24, 2004
  2. Guybrush Threepwood

    Table-based layout to CSS layout

    Guybrush Threepwood, Jun 6, 2006, in forum: HTML
    Replies:
    20
    Views:
    1,004
  3. Replies:
    1
    Views:
    572
    John Timney \(MVP\)
    Jun 19, 2006
  4. Habib

    Css-Layout vs Table-Layout

    Habib, Jun 19, 2006, in forum: HTML
    Replies:
    15
    Views:
    1,010
    Wÿrm
    Jun 20, 2006
  5. sso
    Replies:
    6
    Views:
    592
    Roedy Green
    Apr 30, 2009
Loading...

Share This Page