Solved

dynamic rowspans

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using AJAX to call classic ASP function 4 84
EOF BOF error classic asp 8 43
Display first 3 lines of text from database field, vbscript asp 4 49
ASP Button to clear text 4 44
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 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

22 Experts available now in Live!

Get 1:1 Help Now