Solved

dynamic rowspans

Posted on 2000-03-22
5
976 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 …
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 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

16 Experts available now in Live!

Get 1:1 Help Now