SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2005
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Formating Needed for numbers and text in <td>

    Hi,

    I am using a table to show some data the first row shows some txt and the
    other rows show numbers e.g.

    Stid stweight( in kgs )
    1 80.4
    2 70.5
    3 70.999

    Now I want to align the first row center-algned and the other left-aligned
    but the problem is that the data is dynamic filled in the table using a loop so we never know when is the text coming and when are numbers coming.
    Is ther anyway through which we can align the text cetered and the numbers left.

    Also I want the numbers to be showed in three decimals e.g. 80.4000 and 70.500 etc..


    Thanks,

  2. #2
    SitePoint Guru babyboy808's Avatar
    Join Date
    Nov 2004
    Location
    dublin
    Posts
    602
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, What Scriptiing language are you using?

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2005
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am using VBscript and ASP.

  4. #4
    SitePoint Guru babyboy808's Avatar
    Join Date
    Nov 2004
    Location
    dublin
    Posts
    602
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah ok, I can prop give you the solution in PHP, but not ASP

  5. #5
    SitePoint Zealot
    Join Date
    Sep 2005
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is the coding...

    ..............................................

    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.Open "Provider=MSDAORA;Data Source=compas;User Id=compas_isbx002;Password=isbx002;"
    dim vv
    vv=request.querystring("btn")


    Set objRs = objConn.Execute("SELECT STORED_COMMODITIES.COMMODITY_CODE Commodity,Sum(STORED_COMMODITIES.NUMBER_OF_UNITS) Units, Sum(STORED_COMMODITIES.QUANTITY_NET) Net, Sum(STORED_COMMODITIES.QUANTITY_GROSS) Gross FROM STORED_COMMODITIES where STORED_COMMODITIES.OFFID='"&vv&"' GROUP BY STORED_COMMODITIES.COMMODITY_CODE")
    Response.Write "<table border=1 cellpadding=4>"
    Response.Write "<tr>"

    For I = 0 To objRS.Fields.Count - 1
    Response.Write "<td align=center><b>" & objRS(I).Name & "</b></td>"
    Next

    Response.Write "</tr>"

    Do While Not objRS.EOF
    Response.Write "<tr>"

    For I = 0 To objRS.Fields.Count - 1
    Response.Write "<td align=center>" & objRS(I) & "</td>"
    Next

    Response.Write "</tr>"

    objRS.MoveNext
    Loop

    Response.Write "</table>"



    objRs.Close
    objConn.Close
    ...............................

    I guess the bolded <td> is needed to be changed

  6. #6
    SitePoint Guru babyboy808's Avatar
    Join Date
    Nov 2004
    Location
    dublin
    Posts
    602
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One way might be to use CSS to preformat your table, so when "the text is coming" you don't need to code any formatting

  7. #7
    SitePoint Zealot
    Join Date
    Sep 2005
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep may be but latter.

    For the time being I want something much simpler.

    Thanks,


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •