...

View Full Version : how can i display the data in group heading from 2 table?



jltwwmk
08-01-2004, 02:25 AM
this code work
but how can i display the data in group heading of department from 2 table?
thanks
asp beginner

<html>
<head>
<title>display in department group heading</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-874">
<link rel="STYLESHEET" type="text/css" href="style.css">
</head>
<body>
<%
Set Conndb = Server.createObject("ADODB.Connection")
Conndb.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& Server.MapPath("/../db/recruit.mdb")
Sql = "SELECT * FROM recruit,Department WHERE recruit.DepartmentID = Department.DepartmentID"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open Sql, Conndb,1,3
%>
<table border=1>
<% Do While Not Rs.Eof %>
<tr>
<td colspan=2><center><%=Rs("DepartmentT")%></center></td>
</tr>
<tr>
<td colspan=2><center><%=Rs("Department.DepartmentID")%></center></td>
</tr>
<tr>
<td colspan=2><center><%=Rs("recruit.DepartmentID")%></center></td>
</tr>
<tr>
<td ><%=Rs("NameT")%></td>
<td ><%=Rs("qualification")%></td>
</tr>
<%Rs.MoveNext
Loop %>
<%Rs.Close
set Rs = Nothing%>
</table>
</body>
</html>
<%
Conndb.Close
Set Conndb = Nothing
%>

startbar
08-01-2004, 09:54 AM
what do you mean?

do you want to sort the data by the heading department?

be more precise! :)

jltwwmk
08-01-2004, 03:30 PM
i mean that
how to write asp code for displaying the data in group heading of department like this

department_a
1.name1a qualification1a
2.name2a qualification2a
3.name3a qualification3a
4.name4a qualification4a
....
....
9.name9a qualification9a

department_b
1.name1b qualification1b
2.name2b qualification2b
....
....
....
25.name25b qualification25b
department_c
1.......
2......
3......

thanks

Roy Sinclair
08-03-2004, 10:06 PM
What you want to do seems obvious to those of us who were coding on mainframes when paper reports were the preferred medium :D.

You need to declare and initialize (to an empty value) a variable to store the value of the department field. Then inside your loop you check to see if the value of that variable is equal to the value of the department field for the current database record. If they aren't the same (which they won't be the first time through the loop and any time the department changes) you execute code to set the variable to the new value of department and output the department line to your table.

Does this make sense to you?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum