Dynamic Table help

T

Tony Schlak

Here is the ASP for the page:

<% @LANGUAGE = VBScript %>
<%response.buffer=true%>
<%
Dim objRS
Dim strQuery
Dim strConnection
Dim arrPics
Dim numRows, numRecords, colCounter, displayName, displayPic

Set Session("DB") = Server.CreateObject("ADODB.Connection")
Session("DB").Open("OSC")


strQuery = "SELECT * From vwWebPhoto Order by Name"
Set objRS= Session("DB").Execute(strQuery)

Const numColumns = 5


arrPics = objRS.getrows
%>

<%
Function IsLocal
If Request.QueryString("Local") = "" AND Session("bLocal") = 1 Then
IsLocal = TRUE
Else
IsLocal = FALSE
End If
End Function
%>
<html>
<head>
<script type="text/javascript" src="../include.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Student Pictures</title>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<link rel="STYLESHEET" type="text/css" href="../default2.css">
</head>
<script type="text/javascript">Logo()</script>
<body>

<h1>Current Students</h1>
<table align="center" border="0" cellpadding="1" cellspacing="1">
<%If IsLocal() = True Then%>
<THEAD>
<tr>
<%
For colCounter = 1 to numColumns%>
<%
next
%>
</tr>
</THEAD>
<%
numRecords = ubound(arrPics,2) +1
If numRecords mod numColumns = 0 Then
numRows = numRecords\numColumns
Else
numRows = numRecords\numColumns + 1
End IF

for rowCounter = 1 to numRows
For colCounter = 0 to numColumns-1

if rowCounter + colCounter * numRows <= numRecords then
displayName = arrPics(1, rowCounter + colCounter * numRows-1)
displayPic = arrPics(2, rowCounter +colCounter * numRows-1)

response.write "<td><p align=center><a href=""scripts/profile.asp?DirID="
& arrPics(0, rowCounter + colCounter * numRows-1) & """><img src= " &
displayPic & " /></a><br><text-align=center>" & displayName & "</td>"

Else
Response.write"</tr>"
end if
next
response.write"</tr>"
next
%>
</table>
<%
Else
response.write "<h3 align=center>You are viewing this page outside of the
Optical Science Department</h3>"

End IF%>
<script type="text/javascript">Footer()</script>
</body>
</html>

Right now when it returns the pictures they are arranged like:
A D
B E
C F
I would like:
A B C
D E F

Also the view has info about whether the student is BS or MS or PhD
candidate. I cant seem to figure out how to step into the array and pull
out only the entries with either BS or MS or PhD.

Thanks,

Tony
 
J

Jim Buyens

I would get rid of the array completely, and step through
the recordset like this. (I'm guessing at the field
names.)

reccnt = 0
Do While Not objRS.eof
cellHtml = "<td align=center><a " & _
"href=""scripts/profile.asp?DirID=" & _
objRs("dirid") & """><img src=""" & _
objRS("displayPic") & """><a><br>" & _
objRS("displayName") & "</td>"
select case reccnt mod 3
case 0
response.write "<tr>" & cellHtml
case 1
response.write cellHtml
case else
response.write cellHtml & "</tr>"
end select
reccnt = reccnt + 1
objRS.MoveNext
Loop
if reccnt mod 3 <> 0 then
response.write "</tr>"
end if

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------




-----Original Message-----
Here is the ASP for the page:

<% @LANGUAGE = VBScript %>
<%response.buffer=true%>
<%
Dim objRS
Dim strQuery
Dim strConnection
Dim arrPics
Dim numRows, numRecords, colCounter, displayName, displayPic

Set Session("DB") = Server.CreateObject ("ADODB.Connection")
Session("DB").Open("OSC")


strQuery = "SELECT * From vwWebPhoto Order by Name"
Set objRS= Session("DB").Execute(strQuery)

Const numColumns = 5


arrPics = objRS.getrows
%>

<%
Function IsLocal
If Request.QueryString("Local") = "" AND Session ("bLocal") = 1 Then
IsLocal = TRUE
Else
IsLocal = FALSE
End If
End Function
%>
<html>
<head>
<script type="text/javascript"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top