[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 996
  • Last Modified:

dynamic rowspans

hi...
how can i generate dynamic rowspan's...
i mean that situation:
im retrieving records from db:

date         name   item
----        ----   -----
1/1/00      david  table
1/1/00      david  chair
1/1/00      david  car
1/1/00      bill   book

but,i want to display on
the screen this:

date      name      item
----      -----      ----
1/1/00      david      table
            chair
            car
      bill      book
0
eladr
Asked:
eladr
1 Solution
 
eladrAuthor Commented:
i mean this:
date      name      item
----      -----      ----
1/1/00      david      table
                chair
                car
      bill      book
0
 
CJ_SCommented:
well, if the record you are reading is empty then just do a <td></td>
Oh...you mean that you want a string OVER multiple td's???

yu do that using the colspan like:

<table>
  <tr>
    <td>uno</td><td>duo</td>
  </tr>
  <tr>
    <td colspan=2><center>trio</center></td>
  </tr>
</table>

just suit yourself with the information you retrieve out of the database....
0
 
eladrAuthor Commented:
you didnt understand my quetion.
see it again...
i dont want the date and the name "david" in this case will appear more than one.

elad
0
 
mgfranzCommented:
YOu would just pass the SQL string the parameters required to match;

SQL = "SELECT Date, Name, Item FROM TABLE WHERE Name = '" & Request.Form("Name") &"'"

Then it's simply a matter of looping through the data to write the Items;

<%
If Not rs.eof Then
%>
<tr bgcolor="#cbcb96" >
<td align="middle"><% = rs.Fields("Name") %></td>
<td  align="middle"><%= rs.Fields("Date") %>
</td>
</tr>
<%
On Error Resume Next
rs.MoveFirst
do while Not rs.eof
%>
<tr valign="top">
<td  valign="top" width=60>
<%=Server.HTMLEncode(rs.Fields("Name").Value)%></td>
</tr>
<%
rs.MoveNext
loop
%>


You will have to play with the tables and rowspans and such...
0
 
doantu01Commented:
ELADR ,I think no need to do such your very dificult way.
Instead, you have many choice
Like CJ_S, you can place a blank cell if you don't want display same data as previous record.I think it is the simplest. Or you can use nested table.
In the following sample I use nested table:
=======================
there are 3 fields:sdate,sname,sitem in my RowSpan table

<%
dim dbcnn
dim rcs
dim prename,predate
set dbcnn=Server.CreateObject("ADODB.Connection")
dbcnn.Open "RowSpan","sa",""
set rcs=dbcnn.Execute("Select * from RowSpan order by sdate,sname")
if (not(rcs.eof and rcs.bof)) then
%>
<table border=1 width=100%>
<tr><td>Date</td><td width=25%>Name</td><td width=25%>Item</td></tr>
<%
      do while not rcs.eof
      predate=rcs.fields("sdate")
%>
      <tr>
      <td><%=predate%></td>
      <td colspan=2>
      <table border=0 width=100%>
      <%
      do while (predate=rcs.fields("sdate"))
      prename=rcs.fields("sname")
      %>
      <tr>
      <td width=50%><%=prename%></td>
      <td>
      <table border=0>
            <%
                  do while (predate=rcs.fields("sdate")) and (prename=rcs.fields("sname"))
                  %>
                  <tr><td><%=rcs.fields("sitem")%></td></tr>
                  <%
                  rcs.movenext                  
                  if rcs.eof then
                        exit do
                  end if
                  loop
            %>
      </table>
      </td>
      </tr>
      <%
      if rcs.eof then
            exit do
      end if
      loop
      %>
      </table>
      </td>
      </tr>
<%
      loop
%>
</table>
<%
else
      Response.Write("Record is empty")
end if
rcs.close
dbcnn.Close()
set rcs=nothing
set dbcnn=nothing
%>
=======================
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now