Solved

dynamic rowspans

Posted on 2000-03-22
5
985 Views
Last Modified: 2010-05-18
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
Comment
Question by:eladr
5 Comments
 
LVL 1

Author Comment

by:eladr
ID: 2644648
i mean this:
date      name      item
----      -----      ----
1/1/00      david      table
                chair
                car
      bill      book
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2645007
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
 
LVL 1

Author Comment

by:eladr
ID: 2645097
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
 
LVL 18

Expert Comment

by:mgfranz
ID: 2646151
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
 

Accepted Solution

by:
doantu01 earned 5 total points
ID: 2646267
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

809 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