Solved

How can i order these elements on the page(a newbie question)

Posted on 2004-10-23
143 Views
Last Modified: 2010-04-09
Hello all experts,
i have got a page that displays a piechart on it at the left of the page ,and another data that are driven from the db (code written in ASP).How can i put the data displayed in this page beside the piechart which is added as an include file.
I want all of them to be beside each other not under each other :
I want The piechart at the left and beside it the other data.
Here is the code of the page:
<!-- METADATA TYPE="typelib" FILE="D:\Program Files\Common Files\System\ado\msado15.dll" -->

<%@ Language = VBScript %>
<%Option Explicit%>
<!--#include file="pie-chart.asp"-->

<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<%
'coding by Lijun Guo of Astratel
dim  strDataPath, strConnectString, objConnection
'define valuables to store the total
dim t_calories, t_cholesterol, t_sodium, t_fatgrams,rs, sql_get, t_Saturated_Fat
dim dayofweek, d_date, int_days,int_rows, int_totals
dim foodtype, calories, fatgrams,cholesterol, counter, sodium ,Saturated_Fat
     int_days  = 0
     int_totals = 0
     int_rows = 0
     d_date = 0
     t_calories = 0
     t_cholesterol = 0
     t_sodium = 0
     t_fatgrams = 0
       t_Saturated_Fat = 0
     'set connection strings for entire application
     strDataPath = server.MapPath("DB1.mdb")
     strConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;"_
              + " Data Source= " & strDataPath & ";"_
             + " Mode=Share Deny None;User Id=admin;PASSWORD=;"
     'strConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;  Data Source=D:\astratel\test\Db1.mdb; Persist Security Info=False"
               
     if not IsObject("ojbConnection") then
         set objConnection=Server.CreateObject("ADODB.Connection")
         objConnection.ConnectionTimeout = 15
         objConnection.CommandTimeout =  10
          objConnection.Mode = 3 'adModeReadWrite
          if objConnection.state = 0 then
               objConnection.Open strConnectString
          end if
     end if


     'objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;  Data Source=D:\astratel\test\Db1.mdb; Persist Security Info=False"
    set rs = Server.CreateObject("ADODB.Recordset")
     sql_get = "select * from temp where MEMBER_ID = " & Session("MEMBER_ID") & " order by d_date"
     'rs.Open sql_get, objConnection
     rs.Open sql_get, objConnection, adOpenstatic, adLockOptimistic, adCmdText



%>


<table width="600" bordercolor="#000000">
  <tr>
    <td colspan="5" height="21">&nbsp;</td>
  </tr>
  <% while not rs.Eof
          foodtype = rs("Foodtype")
          calories = rs("Calories")
          fatgrams = rs("Fatgrams")
          cholesterol = rs("Cholesterol")
          fatgrams = rs("Sodium")
          cholesterol = rs("Saturated_Fat")
              d_date = Weekday(rs("d_date"))
          Select case d_date
          case 1
              dayofweek = "Sunday"
          case 2
              dayofweek = "Monday"
          case 3
              dayofweek = "Tuesday"
          case 4
              dayofweek = "Wednesday"
          case 5
              dayofweek = "Thursday"
          case 6
              dayofweek = "Friday"
          case 7
              dayofweek = "Saturday"
          End Select      

          if int_days  <> Weekday(rs("d_date")) then
               int_days = Weekday(rs("d_date"))
               int_totals = 0 'loop for different days only
               t_calories = 0
               t_cholesterol = 0
               t_fatgrams = 0
               t_Saturated_Fat = 0
               t_Sodium = 0
                    
                     int_rows = 0'show once only for each day
               'reset the variables for each day
  %>
  <tr>
    <td height="20" valign="top" colspan="3" > <b><font face='Arial' size=4 color=85A554>
      <% =Response.Write(dayofweek) & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & rs("d_date") %>
      </font></b> </td>
    <td width="149"></td>
    <td width="294"></td>
  </tr>
  <tr>
    <td width="36"></td>
    <td></td>
    <td></td>
  </tr>
  <% End if %>
  <% While      int_rows < 9 and rs.eof = false
  if (int_days = Weekday(rs("d_date")))  then %>
  <tr>
    <td valign="top" height="18" colspan="2"><font face='Arial' size=2 color=85A554>
      Item selected: </font></td>
 
    <td colspan="3" valign="top"><font face='Arial' size=4 color=FF9900><%=Response.Write( "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;") & rs("Foodtype")  %> </font>
      <% 'loop the same day for different foodtypes and get the totals
if rs("Calories") <> "" then
     t_calories = t_calories + CInt(rs("Calories") )
End if
if rs("Fatgrams") <>"" then
     t_fatgrams = t_fatgrams + CInt(rs("Fatgrams"))
End if
if rs("Cholesterol") <> "" then
     t_cholesterol = t_cholesterol + CInt(rs("Cholesterol"))
End if
if rs("Sodium") <>"" then
     t_Sodium = t_Sodium + CInt(rs("Sodium"))
End if
if rs("Saturated_Fat") <> "" then
     t_Saturated_Fat = t_Saturated_Fat + CInt(rs("Saturated_Fat"))
End if
        %>
    </td>
    <td></td>
  </tr>
  <%
        int_rows = int_rows  + 1
      rs.MoveNext
      else
            int_rows = 9  'break the loop
      End if
      Wend
        if int_totals = 0 then
  %>
  <tr>
    <td colspan="5" height="21"> totalcholesterol : <%=t_cholesterol%> </td>
  </tr>
  <tr>
    <td colspan="5" height="21"> total fatgram: <%= t_fatgrams%> </td>
  </tr>
  <tr>
    <td colspan="5" height="21">Total calories : <%= t_calories%></td>
  </tr>
  <tr>
    <td colspan="5" height="21"> total sodium: <%= t_Sodium%> </td>
  </tr>
  <tr>
    <td colspan="5" height="21">Total Saturated_Fat : <%= t_Saturated_Fat%></td>
  </tr>
  <tr>
    <td colspan="5" height="21">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="5" height="21">&nbsp;</td>
  </tr>
  <tr>
    <td height="5"></td>
    <td width="50"></td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
  <%End if
  int_totals= int_totals + 1
  Wend %>
</table>
</BODY>
<%
     rs.close
     set rs = nothing
     objConnection.Close
     set objConnection = Nothing
%>

</HTML>
0
Question by:Melfeky
    15 Comments
     
    LVL 8

    Accepted Solution

    by:
    wrap another table around it:

    <table>
    <tr>
        <td valign="top">
            <!-- your chart include goes here --->
        </td>
        <td valign="top">
            <!-- the two tables in your code above, which I am assuming is your data, go here --->
        </td>
    </tr>
    </table>
    0
     
    LVL 31

    Assisted Solution

    by:seanpowell
    Just float your data table:

    <table width="600" bordercolor="#000000" style="float:right;">

    Sean
    0
     

    Author Comment

    by:Melfeky
    seanpowell:
    Where shall i add this line:
    <table width="600" bordercolor="#000000" style="float:right;">
    0
     
    LVL 31

    Expert Comment

    by:seanpowell
    Where you have this:

    <table width="600" bordercolor="#000000">

    change it to this:

    <table width="600" bordercolor="#000000" style="float:right;">

    Thanks,
    Sean
    0
     

    Author Comment

    by:Melfeky
    Well thanks sean but still the same
    0
     
    LVL 8

    Expert Comment

    by:sigmacon
    melfeky, altthough I'd prefer Sean's css-based approach, have you tried my suggestion yet?
    0
     

    Author Comment

    by:Melfeky
    i have tried urs but everything is in a mess.
    I don't know how to fix this .Have u any idea?
    0
     

    Author Comment

    by:Melfeky
    Would u check this link:

    http://ccc.1asphost.com/kotty1234/Copy%20of%20Copy%20of%20crash/newlogin.ASP
    username:user1
    password:pass
     
    click the "Journal "button u will be directed to the page that i am talking about .sorry for all this steps but this is how it works.
    thanks,
    0
     
    LVL 8

    Expert Comment

    by:sigmacon
    What do you mean with 'everything is a mess'? You'll need to clarify this, so I can provide some input. Maybe you want to post the HTML that is the result after you included the chart? Than we could fix that and you can put the dynamic parts back in. It's hard to do HTML design on incomplete templates.
    0
     

    Author Comment

    by:Melfeky
    Here is the code after i have modified it.
    <!-- METADATA TYPE="typelib" FILE="D:\Program Files\Common Files\System\ado\msado15.dll" -->

    <%@ Language = VBScript %>
    <%Option Explicit%>




    <%
    'coding by Lijun Guo of Astratel
    dim  strDataPath, strConnectString, objConnection
    'define valuables to store the total
    dim t_calories, t_cholesterol, t_sodium, t_fatgrams,rs, sql_get, t_Saturated_Fat
    dim dayofweek, d_date, int_days,int_rows, int_totals
    dim foodtype, calories, fatgrams,cholesterol, counter, sodium ,Saturated_Fat
         int_days  = 0
         int_totals = 0
         int_rows = 0
         d_date = 0
         t_calories = 0
         t_cholesterol = 0
         t_sodium = 0
         t_fatgrams = 0
           t_Saturated_Fat = 0
         'set connection strings for entire application
         strDataPath = server.MapPath("DB1.mdb")
         strConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;"_
                  + " Data Source= " & strDataPath & ";"_
                 + " Mode=Share Deny None;User Id=admin;PASSWORD=;"
         'strConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;  Data Source=D:\astratel\test\Db1.mdb; Persist Security Info=False"
                   
         if not IsObject("ojbConnection") then
             set objConnection=Server.CreateObject("ADODB.Connection")
             objConnection.ConnectionTimeout = 15
             objConnection.CommandTimeout =  10
              objConnection.Mode = 3 'adModeReadWrite
              if objConnection.state = 0 then
                   objConnection.Open strConnectString
              end if
         end if


         'objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;  Data Source=D:\astratel\test\Db1.mdb; Persist Security Info=False"
        set rs = Server.CreateObject("ADODB.Recordset")
         sql_get = "select * from temp where MEMBER_ID = " & Session("MEMBER_ID") & " order by d_date"
         'rs.Open sql_get, objConnection
         rs.Open sql_get, objConnection, adOpenstatic, adLockOptimistic, adCmdText



    %>

    <table>
    <BR>
    <tr>
    <BR>   
    <td valign="top">

      <!--#include file="pie-chart.asp"-->
    </td>
     <td valign="top">
     <BR>
      <% while not rs.Eof
              foodtype = rs("Foodtype")
              calories = rs("Calories")
              fatgrams = rs("Fatgrams")
              cholesterol = rs("Cholesterol")
              fatgrams = rs("Sodium")
              cholesterol = rs("Saturated_Fat")
                  d_date = Weekday(rs("d_date"))
              Select case d_date
              case 1
                  dayofweek = "Sunday"
              case 2
                  dayofweek = "Monday"
              case 3
                  dayofweek = "Tuesday"
              case 4
                  dayofweek = "Wednesday"
              case 5
                  dayofweek = "Thursday"
              case 6
                  dayofweek = "Friday"
              case 7
                  dayofweek = "Saturday"
              End Select      

              if int_days  <> Weekday(rs("d_date")) then
                   int_days = Weekday(rs("d_date"))
                   int_totals = 0 'loop for different days only
                   t_calories = 0
                   t_cholesterol = 0
                   t_fatgrams = 0
                   t_Saturated_Fat = 0
                   t_Sodium = 0
                        
                         int_rows = 0'show once only for each day
                   'reset the variables for each day
      %>
     
          <% =Response.Write(dayofweek) & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & rs("d_date") %>
         
      <% End if %>
      <% While      int_rows < 9 and rs.eof = false
      if (int_days = Weekday(rs("d_date")))  then %>
     
     
        <font face='Arial' size=4 color=FF9900><%=Response.Write( "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;") & rs("Foodtype")  %> </font>
          <% 'loop the same day for different foodtypes and get the totals
    if rs("Calories") <> "" then
         t_calories = t_calories + CInt(rs("Calories") )
    End if
    if rs("Fatgrams") <>"" then
         t_fatgrams = t_fatgrams + CInt(rs("Fatgrams"))
    End if
    if rs("Cholesterol") <> "" then
         t_cholesterol = t_cholesterol + CInt(rs("Cholesterol"))
    End if
    if rs("Sodium") <>"" then
         t_Sodium = t_Sodium + CInt(rs("Sodium"))
    End if
    if rs("Saturated_Fat") <> "" then
         t_Saturated_Fat = t_Saturated_Fat + CInt(rs("Saturated_Fat"))
    End if
            %>
       
      <%
            int_rows = int_rows  + 1
          rs.MoveNext
          else
                int_rows = 9  'break the loop
          End if
          Wend
            if int_totals = 0 then
      %>
      <tr>
        <td colspan="5" height="21"> totalcholesterol : <%=t_cholesterol%> </td>
      </tr>
      <tr>
        <td colspan="5" height="21"> total fatgram: <%= t_fatgrams%> </td>
      </tr>
      <tr>
        <td colspan="5" height="21">Total calories : <%= t_calories%></td>
      </tr>
      <tr>
        <td colspan="5" height="21"> total sodium: <%= t_Sodium%> </td>
      </tr>
      <tr>
        <td colspan="5" height="21">Total Saturated_Fat : <%= t_Saturated_Fat%></td></tr><%End if
      int_totals= int_totals + 1
      Wend %><%
         rs.close
         set rs = nothing
         objConnection.Close
         set objConnection = Nothing
    %>
    </td><BR></tr><BR></table>
    0
     
    LVL 8

    Expert Comment

    by:sigmacon
    take out the line breaks between the table-related tags:

    <table>
    <tr>
    <td valign="top">

    </td></tr></table>

    Also, I requested the RESULTING HTML as you deliver it to the browser. Do a 'view source' on the "mess" ;-)
    0
     

    Author Comment

    by:Melfeky
    Ok i removed the <br> and still a mess ,
    i have removed all the html and left only
    <table>
    <tr>
    <td valign="top">

    </td></tr></table>
    But still nothing.
    here is the code  would u tell me how to arrange this?

    <!-- METADATA TYPE="typelib" FILE="c:\Program Files\Common Files\System\ado\msado15.dll" -->

    <%@ Language = VBScript %>
    <%Option Explicit%>




    <%
    'coding by Lijun Guo of Astratel
    dim  strDataPath, strConnectString, objConnection
    'define valuables to store the total
    dim t_calories, t_cholesterol, t_sodium, t_fatgrams,rs, sql_get, t_Saturated_Fat
    dim dayofweek, d_date, int_days,int_rows, int_totals
    dim foodtype, calories, fatgrams,cholesterol, counter, sodium ,Saturated_Fat
         int_days  = 0
         int_totals = 0
         int_rows = 0
         d_date = 0
         t_calories = 0
         t_cholesterol = 0
         t_sodium = 0
         t_fatgrams = 0
           t_Saturated_Fat = 0
         'set connection strings for entire application
         strDataPath = server.MapPath("DB1.mdb")
         strConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;"_
                  + " Data Source= " & strDataPath & ";"_
                 + " Mode=Share Deny None;User Id=admin;PASSWORD=;"
         'strConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;  Data Source=D:\astratel\test\Db1.mdb; Persist Security Info=False"
                   
         if not IsObject("ojbConnection") then
             set objConnection=Server.CreateObject("ADODB.Connection")
             objConnection.ConnectionTimeout = 15
             objConnection.CommandTimeout =  10
              objConnection.Mode = 3 'adModeReadWrite
              if objConnection.state = 0 then
                   objConnection.Open strConnectString
              end if
         end if


         'objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;  Data Source=D:\astratel\test\Db1.mdb; Persist Security Info=False"
        set rs = Server.CreateObject("ADODB.Recordset")
         sql_get = "select * from temp where MEMBER_ID = " & Session("MEMBER_ID") & " order by d_date"
         'rs.Open sql_get, objConnection
         rs.Open sql_get, objConnection, adOpenstatic, adLockOptimistic, adCmdText



    %>

    <table>



    <td >

      <!--#include file="pie-chart.asp"-->
    </td>
     <td valign="top">
     
      <% while not rs.Eof
              foodtype = rs("Foodtype")
              calories = rs("Calories")
              fatgrams = rs("Fatgrams")
              cholesterol = rs("Cholesterol")
              fatgrams = rs("Sodium")
              cholesterol = rs("Saturated_Fat")
                  d_date = Weekday(rs("d_date"))
              Select case d_date
              case 1
                  dayofweek = "Sunday"
              case 2
                  dayofweek = "Monday"
              case 3
                  dayofweek = "Tuesday"
              case 4
                  dayofweek = "Wednesday"
              case 5
                  dayofweek = "Thursday"
              case 6
                  dayofweek = "Friday"
              case 7
                  dayofweek = "Saturday"
              End Select      

              if int_days  <> Weekday(rs("d_date")) then
                   int_days = Weekday(rs("d_date"))
                   int_totals = 0 'loop for different days only
                   t_calories = 0
                   t_cholesterol = 0
                   t_fatgrams = 0
                   t_Saturated_Fat = 0
                   t_Sodium = 0
                        
                         int_rows = 0'show once only for each day
                   'reset the variables for each day
      %>
     
          <% =Response.Write(dayofweek) & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & rs("d_date") %>
         
      <% End if %>
      <% While      int_rows < 9 and rs.eof = false
      if (int_days = Weekday(rs("d_date")))  then %>
      <TR>
      <TD>
        <b><font face='Arial' size=2 color=FF9900><%=Response.Write( "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;") & rs("Foodtype")  %> </font></b>
          <% 'loop the same day for different foodtypes and get the totals
    if rs("Calories") <> "" then
         t_calories = t_calories + CInt(rs("Calories") )
    End if
    if rs("Fatgrams") <>"" then
         t_fatgrams = t_fatgrams + CInt(rs("Fatgrams"))
    End if
    if rs("Cholesterol") <> "" then
         t_cholesterol = t_cholesterol + CInt(rs("Cholesterol"))
    End if
    if rs("Sodium") <>"" then
         t_Sodium = t_Sodium + CInt(rs("Sodium"))
    End if
    if rs("Saturated_Fat") <> "" then
         t_Saturated_Fat = t_Saturated_Fat + CInt(rs("Saturated_Fat"))
    End if
            %>
       
      <%
            int_rows = int_rows  + 1
          rs.MoveNext
          else
                int_rows = 9  'break the loop
          End if
          Wend
            if int_totals = 0 then
      %>
     
     
        Total Cholesterol : <%=t_cholesterol%>
     
     
       total fatgram: <%= t_fatgrams%>
     
     
        Total calories : <%= t_calories%>
     
       
         total sodium: <%= t_Sodium%>
     

       Total Saturated_Fat : <%= t_Saturated_Fat%><%End if
      int_totals= int_totals + 1
      Wend %><%
         rs.close
         set rs = nothing
         objConnection.Close
         set objConnection = Nothing
    %>
    </td></table>
    0
     
    LVL 8

    Expert Comment

    by:sigmacon
    Now you also removed the <tr>s! You need to keep them. Just remove the <br>s and put the <tr>s back in!

    Unless you post the HTML code of generated page as it shows in your browser, I cannot help you any further. Sorry.
    0
     

    Author Comment

    by:Melfeky
    well i did added the <tr>s but still the same .
    Any way thanks for trying to help.
    0
     
    LVL 31

    Expert Comment

    by:seanpowell
    Hi Melfeky, I'm afraid you code has a number of errors regarding basic html syntax.
    Until we can start off with a well formed document, there's not much we can do for you.

    I need to be blunt here - do you have access to anyone with some basic html formatting knoweldge, it would help us be able to help you if we could get the code up to par.

    Thanks,
    Sean



    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    A colleague recently asked me about how to give his client a small part of the web site that could be completely under the client's control.  Since I have done this sort of thing before to add emergency banners to a web site, I decided I would creat…
    This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
    In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
    In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

    857 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now