|
 |
asp_databases thread: how?
Message #1 by Marios Adamantopoulos <mario@T...> on Thu, 22 Mar 2001 14:30:35 -0000
|
|
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C0B2DC.A8C5F50E
Content-Type: text/plain;
charset="iso-8859-1"
Hi all,
since I am a beginner in ASP I can simple questions right?
I have about 20 artists in my database and what I need to do is to output
them on my page
in the following way
---------------------------------
artist1 | artist5 | artist9 |
artist2 | artist6 | artist10|
artist3 | artist7 | artist11|
artist4 | artist8 | artist12|
---------------------------------
that list is going to change though. If I choose a specific topic
I might get only 5 artists back, or 2
Anyone can help?
_____________________
Marios Adamantopoulos
Web Developer
Tonic Design Limited
Studio 2, Church Studios
Camden Park Road
London NW1 9AY
Tel +44 (0)20 7691 2227
Fax +44 (0)20 7691 2228
Mob +44(0)7904 221 663
www.tonicdesign.co.uk
............................................................................
....................................
Opinions, conclusions and other information in this message
that do not relate to the official business of Tonic Design Ltd
shall be understood as neither given nor endorsed by them.
............................................................................
....................................
Message #2 by Gregory_Griffiths@c... on Thu, 22 Mar 2001 15:05:58 +0000
|
|
Try something like
start table
loop until end of data
open table row
first cell
if data returned add it
else add a space
second cell
if data returned add it
else add a space
third cell
if data returned add it
else add a space
close table row
end loop
end table
I don't have an ASP ref. handy to give you some samepl code, but I'll
try to put some together unless someone else gets their first.
-----Original Message-----
From: mario@T... [mailto:mario@T...]
Sent: 22 March 2001 14:31
To: asp_databases@p...
Cc: mario@T...
Subject: [asp_databases] how?
Hi all,
since I am a beginner in ASP I can simple questions right?
I have about 20 artists in my database and what I need to do is to
output them on my page
in the following way
---------------------------------
artist1 | artist5 | artist9 |
artist2 | artist6 | artist10|
artist3 | artist7 | artist11|
artist4 | artist8 | artist12|
---------------------------------
that list is going to change though. If I choose a specific topic
I might get only 5 artists back, or 2
Anyone can help?
_____________________
Marios Adamantopoulos
Web Developer
Tonic Design Limited
Studio 2, Church Studios
Camden Park Road
London NW1 9AY
Tel +44 (0)20 7691 2227
Fax +44 (0)20 7691 2228
Mob +44(0)7904 221 663
www.tonicdesign.co.uk
........................................................................
........................................
Opinions, conclusions and other information in this message
that do not relate to the official business of Tonic Design Ltd
shall be understood as neither given nor endorsed by them.
........................................................................
........................................
Message #3 by "Daniel O'Dorisio" <dodorisio@h...> on Thu, 22 Mar 2001 10:43:09 -0500
|
|
---------------------------------------
: start table
: loop until end of data
: open table row
: first cell
: if data returned add it
: else add a space
: second cell
: if data returned add it
: else add a space
: third cell
: if data returned add it
: else add a space
: close table row
: end loop
: end table
----------------------------------------
this will give him an infinite loop... you aren't moving to the next
record.. and if you did, it would give him this:
---------------------------------
artist1 | artist1 | artist1|
artist2 | artist2 | artist2|
artist3 | artist3 | artist3|
artist4 | artist4 | artist4|
---------------------------------
here is what I would do:
Dim num
Dim objrs
set objrs = Server.Creatobject("ADODB.Recordset")
objrs.open "SELECT <whatever> FROM <wherever> WHERE <clause>", connstring
Response.Write "<table border=""0"">"
num = 0
Do until objrs.eof
'open a new row if needed
If num = 0 then
Response.Write "<tr>"
End if
'write the contents
Response.Write "<td>" & objrs("value") & "</td>"
'increment the num
num = num + 1
'close the row if needed
If num = 2 Then
Response.Write "</tr>"
'set num back to 0 to start the process for a new row
num = 0
End If
'move to the next record. if this isn't done you will get an infinite
loop:-)
objrs.MoveNext
Loop
' you might need to do this as well, I'm not sure. I haven't "played"
' with the code, so I don't know if it will work great. but depending
' on the number of records, the table row wont get closed, so I would
' add this:
If num < 2 then Response.Write "</td>"
objrs.close
set objrs = nothing
this should give you:
---------------------------------
artist1 | artist2 | artist3|
artist4 | artist5 | artist6|
artist7 | artist8 | artist9|
artist10 | artist11 | artist12|
---------------------------------
if you want it in the other order (top to bottom, left to right, instead of
left to right, top to bottom) let me think on it for a sec:-) and play some.
Daniel
-----Original Message-----
From: Gregory_Griffiths@c...
[mailto:Gregory_Griffiths@c...]
Sent: Thursday, March 22, 2001 10:06 AM
To: ASP Databases
Subject: [asp_databases] RE: how?
Try something like
start table
loop until end of data
open table row
first cell
if data returned add it
else add a space
second cell
if data returned add it
else add a space
third cell
if data returned add it
else add a space
close table row
end loop
end table
I don't have an ASP ref. handy to give you some samepl code, but I'll
try to put some together unless someone else gets their first.
-----Original Message-----
From: mario@T... [mailto:mario@T...]
Sent: 22 March 2001 14:31
To: asp_databases@p...
Cc: mario@T...
Subject: [asp_databases] how?
Hi all,
since I am a beginner in ASP I can simple questions right?
I have about 20 artists in my database and what I need to do is to
output them on my page
in the following way
---------------------------------
artist1 | artist5 | artist9 |
artist2 | artist6 | artist10|
artist3 | artist7 | artist11|
artist4 | artist8 | artist12|
---------------------------------
that list is going to change though. If I choose a specific topic
I might get only 5 artists back, or 2
Anyone can help?
_____________________
Marios Adamantopoulos
Web Developer
Tonic Design Limited
Studio 2, Church Studios
Camden Park Road
London NW1 9AY
Tel +44 (0)20 7691 2227
Fax +44 (0)20 7691 2228
Mob +44(0)7904 221 663
www.tonicdesign.co.uk
........................................................................
........................................
Opinions, conclusions and other information in this message
that do not relate to the official business of Tonic Design Ltd
shall be understood as neither given nor endorsed by them.
........................................................................
........................................
Message #4 by Marios Adamantopoulos <mario@T...> on Thu, 22 Mar 2001 18:01:29 -0000
|
|
Thanks all, for your responses,
the thing is that I don't want to scan horizontally...
In the first column I have the following(just for testing though;
I don't want all the results on the first table.
--------------
<%
Do while not oRS.EOF
response.write "<a href='portfolio_personal.asp?tonic-id=" &
oRS("artistid") & "&tonic-topicid=" & oRS("topicid") & "'>" &
oRS("artistname") & "</a><br>"
oRS.movenext
loop
%>
--------------
Here is the table I'm trying to create
--------------
<table>
<tr>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">adrian green</a><br>
<a href="portfolio_personal.html">adrian myers</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">adrian green</a><br>
<a href="portfolio_personal.html">adrian myers</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">emma leon</a><br>
<a href="portfolio_personal.html">glyn roberts</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">adrian green</a><br>
<a href="portfolio_personal.html">adrian myers</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
</tr>
</table>
--------------
_____________________
Marios Adamantopoulos
Web Developer
Tonic Design Limited
Studio 2, Church Studios
Camden Park Road
London NW1 9AY
Tel +44 (0)20 7691 2227
Fax +44 (0)20 7691 2228
Mob +44(0)7904 221 663
www.tonicdesign.co.uk
Message #5 by "Owen Mortensen" <ojm@a...> on Thu, 22 Mar 2001 11:28:37 -0700
|
|
So get the count from the Recordset to find out how many items there are
total, divide by three, get the whole recordset out into an array and then
index through the array as you go through the table rows.
Owen
-----Original Message-----
From: Marios Adamantopoulos [mailto:mario@T...]
Sent: Thursday, March 22, 2001 11:01 AM
To: ASP Databases
Subject: [asp_databases] RE: how?
Thanks all, for your responses,
the thing is that I don't want to scan horizontally...
In the first column I have the following(just for testing though;
I don't want all the results on the first table.
--------------
<%
Do while not oRS.EOF
response.write "<a href='portfolio_personal.asp?tonic-id=" &
oRS("artistid") & "&tonic-topicid=" & oRS("topicid") & "'>" &
oRS("artistname") & "</a><br>"
oRS.movenext
loop
%>
--------------
Here is the table I'm trying to create
--------------
<table>
<tr>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">adrian green</a><br>
<a href="portfolio_personal.html">adrian myers</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">adrian green</a><br>
<a href="portfolio_personal.html">adrian myers</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">emma leon</a><br>
<a href="portfolio_personal.html">glyn roberts</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">adrian green</a><br>
<a href="portfolio_personal.html">adrian myers</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
</tr>
</table>
--------------
_____________________
Marios Adamantopoulos
Web Developer
Tonic Design Limited
Studio 2, Church Studios
Camden Park Road
London NW1 9AY
Tel +44 (0)20 7691 2227
Fax +44 (0)20 7691 2228
Mob +44(0)7904 221 663
www.tonicdesign.co.uk
Message #6 by Marios Adamantopoulos <mario@T...> on Thu, 22 Mar 2001 19:58:03 -0000
|
|
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C0B30A.6793C51A
Content-Type: text/plain;
charset="iso-8859-1"
how do you get the count from the recordset?
do I have to put it in the SQL command?
_____________________
Marios Adamantopoulos
Web Developer
Tonic Design Limited
Studio 2, Church Studios
Camden Park Road
London NW1 9AY
Tel +44 (0)20 7691 2227
Fax +44 (0)20 7691 2228
Mob +44(0)7904 221 663
www.tonicdesign.co.uk
............................................................................
....................................
Opinions, conclusions and other information in this message
that do not relate to the official business of Tonic Design Ltd
shall be understood as neither given nor endorsed by them.
............................................................................
....................................
-----Original Message-----
From: Owen Mortensen [mailto:ojm@a...]
Sent: 22 March 2001 18:29
To: ASP Databases
Subject: [asp_databases] RE: how?
So get the count from the Recordset to find out how many items there are
total, divide by three, get the whole recordset out into an array and then
index through the array as you go through the table rows.
Owen
-----Original Message-----
From: Marios Adamantopoulos [mailto:mario@T...]
Sent: Thursday, March 22, 2001 11:01 AM
To: ASP Databases
Subject: [asp_databases] RE: how?
Thanks all, for your responses,
the thing is that I don't want to scan horizontally...
In the first column I have the following(just for testing though;
I don't want all the results on the first table.
--------------
<%
Do while not oRS.EOF
response.write "<a href='portfolio_personal.asp?tonic-id=" &
oRS("artistid") & "&tonic-topicid=" & oRS("topicid") & "'>" &
oRS("artistname") & "</a><br>"
oRS.movenext
loop
%>
--------------
Here is the table I'm trying to create
--------------
<table>
<tr>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">adrian green</a><br>
<a href="portfolio_personal.html">adrian myers</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">adrian green</a><br>
<a href="portfolio_personal.html">adrian myers</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">emma leon</a><br>
<a href="portfolio_personal.html">glyn roberts</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">adrian green</a><br>
<a href="portfolio_personal.html">adrian myers</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
</tr>
</table>
--------------
_____________________
Marios Adamantopoulos
Web Developer
Tonic Design Limited
Studio 2, Church Studios
Camden Park Road
London NW1 9AY
Tel +44 (0)20 7691 2227
Fax +44 (0)20 7691 2228
Mob +44(0)7904 221 663
www.tonicdesign.co.uk
---
SoftArtisans helps developers build robust, scalable Web applications!
Excel Web reports, charts: http://www.softartisans.com/excelwriter.html
File uploads: http://www.softartisans.com/saf.html
Transactional file management: http://www.softartisans.com/saf1.html
Scalability: http://www.softartisans.com/saxsession.html
ASPstudio value pack: http://www.softartisans.com/aspstudiosuite.html
$subst('Email.Unsub')
Message #7 by "Owen Mortensen" <ojm@a...> on Thu, 22 Mar 2001 13:33:36 -0700
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_0026_01C0B2D4.B2637FD0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
RE: [asp_databases] RE: how?Do you have the Wrox book _Beginning Active
Server Pages 3.0_? Appendix C has a good summary of all the methods, etc.
of a Recordset object. Use the RecordCount property of a Recordset object
(making sure you have the right kind of cursor type and location -- someone
jump in here...) to find out how many records you have.
Owen
-----Original Message-----
From: Marios Adamantopoulos [mailto:mario@T...]
Sent: Thursday, March 22, 2001 12:58 PM
To: ASP Databases
Subject: [asp_databases] RE: how?
how do you get the count from the recordset?
do I have to put it in the SQL command?
_____________________
Marios Adamantopoulos
Web Developer
Tonic Design Limited
Studio 2, Church Studios
Camden Park Road
London NW1 9AY
Tel +44 (0)20 7691 2227
Fax +44 (0)20 7691 2228
Mob +44(0)7904 221 663
www.tonicdesign.co.uk
............................................................................
....................................
Opinions, conclusions and other information in this message
that do not relate to the official business of Tonic Design Ltd
shall be understood as neither given nor endorsed by them.
............................................................................
....................................
-----Original Message-----
From: Owen Mortensen [mailto:ojm@a...]
Sent: 22 March 2001 18:29
To: ASP Databases
Subject: [asp_databases] RE: how?
So get the count from the Recordset to find out how many items there are
total, divide by three, get the whole recordset out into an array and then
index through the array as you go through the table rows.
Owen
-----Original Message-----
From: Marios Adamantopoulos [mailto:mario@T...]
Sent: Thursday, March 22, 2001 11:01 AM
To: ASP Databases
Subject: [asp_databases] RE: how?
Thanks all, for your responses,
the thing is that I don't want to scan horizontally...
In the first column I have the following(just for testing though;
I don't want all the results on the first table.
--------------
<%
Do while not oRS.EOF
response.write "<a href='portfolio_personal.asp?tonic-id=" &
oRS("artistid") & "&tonic-topicid=" & oRS("topicid") & "'>" &
oRS("artistname") & "</a><br>"
oRS.movenext
loop
%>
--------------
Here is the table I'm trying to create
--------------
<table>
<tr>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">adrian green</a><br>
<a href="portfolio_personal.html">adrian myers</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0"
alt=""></td>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">adrian green</a><br>
<a href="portfolio_personal.html">adrian myers</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0"
alt=""></td>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">emma leon</a><br>
<a href="portfolio_personal.html">glyn roberts</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0"
alt=""></td>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">adrian green</a><br>
<a href="portfolio_personal.html">adrian myers</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0"
alt=""></td>
</tr>
</table>
--------------
_____________________
Marios Adamantopoulos
Web Developer
Tonic Design Limited
Studio 2, Church Studios
Camden Park Road
London NW1 9AY
Tel +44 (0)20 7691 2227
Fax +44 (0)20 7691 2228
Mob +44(0)7904 221 663
www.tonicdesign.co.uk
---
SoftArtisans helps developers build robust, scalable Web applications!
Excel Web reports, charts: http://www.softartisans.com/excelwriter.html
File uploads: http://www.softartisans.com/saf.html
Transactional file management: http://www.softartisans.com/saf1.html
Scalability: http://www.softartisans.com/saxsession.html
ASPstudio value pack: http://www.softartisans.com/aspstudiosuite.html
$subst('Email.Unsub')
---
SoftArtisans helps developers build robust, scalable Web applications!
Excel Web reports, charts: http://www.softartisans.com/excelwriter.html
File uploads: http://www.softartisans.com/saf.html
Transactional file management: http://www.softartisans.com/saf1.html
Scalability: http://www.softartisans.com/saxsession.html
ASPstudio value pack: http://www.softartisans.com/aspstudiosuite.html
$subst('Email.Unsub')
Message #8 by Marios Adamantopoulos <mario@T...> on Thu, 22 Mar 2001 21:19:35 -0000
|
|
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C0B315.CB531EE2
Content-Type: text/plain;
charset="iso-8859-1"
Finally I made it...
Thanks all for your help, and since you all helped, here is the final code.
I don't know if the techniques I used are good or not, but I think for a
first timer
in a space of two weeks to finish a web site and content management tool,
I did ok...
Any appreciate any comments, but go easy...
Thanks again
Mario
Here is that page
----------------------------------------------
<%
dim objConn
dim strSQL
dim str2SQL
dim topicname
dim categoryname
dim mycount
topicname= Request.QueryString("TOPIC")
categoryname= Request.QueryString("CATEGORY")
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "DSN=somedatabase"
set oRS=server.CreateObject("ADODB.recordset")
set oRS1=server.CreateObject("ADODB.recordset")
set oRS2=server.CreateObject("ADODB.recordset")
if topicname="everybody" and categoryname <> "allfields" then
str2SQL = "SELECT category_id FROM category WHERE category_name ='" &
categoryname & "'"
oRS2.Open str2SQL, objConn
strSQL = "SELECT DISTINCT [artist].[artist_name] AS artistname,
[artist].[artist_id] AS artistid, [topic].[topic_id] AS topicid,
[category].[category_name]"
strSQL = strSQL & " FROM category INNER JOIN ((topic INNER JOIN (artist
INNER JOIN artist_topic ON [artist].[artist_id]=[artist_topic].[artist_id])
ON [topic].[topic_id]=[artist_topic].[topic_id]) INNER JOIN artist_category
ON [artist].[artist_id]=[artist_category].[artist_id]) ON
[category].[category_id]=[artist_category].[category_id]"
strSQL = strSQL & " WHERE ((([artist_topic].[topic_id])=[topic].[topic_id])
And (([artist_topic].[artist_id])=[artist].[artist_id]) And
(([artist_category].[category_id])=" & oRS2("category_id") & ") And
(([artist_category].[artist_id])=[artist].[artist_id]))"
strSQL = strSQL & " ORDER BY [artist].[artist_id]"
oRS.Open strSQL, objConn
oRS2.close
Set oRS2 = Nothing
elseif categoryname = "allfields" and topicname <> "everybody" then
str1SQL = "SELECT topic_id FROM topic WHERE topic_name ='" & topicname &
"'"
oRS1.Open str1SQL, objConn
strSQL = "SELECT [artist].[artist_id] AS artistid, [artist].[artist_name]
AS artistname, [topic].[topic_name], [topic].[topic_id] AS topicid"
strSQL = strSQL & " FROM topic INNER JOIN (artist INNER JOIN artist_topic
ON [artist].[artist_id]=[artist_topic].[artist_id]) ON
[topic].[topic_id]=[artist_topic].[topic_id]"
strSQL = strSQL & " WHERE ((([artist_topic].[topic_id])=" &
oRS1("topic_id") & ") And
(([artist_topic].[artist_id])=[artist].[artist_id]))"
strSQL = strSQL & " ORDER BY [artist].[artist_id]"
oRS.Open strSQL, objConn
oRS1.close
Set oRS1 = Nothing
elseif categoryname = "allfields" and topicname = "everybody" then
strSQL = "SELECT DISTINCT [artist].[artist_name] AS artistname,
[artist].[artist_id] AS artistid, [topic].[topic_id] AS topicid"
strSQL = strSQL & " FROM category INNER JOIN ((topic INNER JOIN (artist
INNER JOIN artist_topic ON [artist].[artist_id]=[artist_topic].[artist_id])
ON [topic].[topic_id]=[artist_topic].[topic_id]) INNER JOIN artist_category
ON [artist].[artist_id]=[artist_category].[artist_id]) ON
[category].[category_id]=[artist_category].[category_id]"
strSQL = strSQL & " WHERE ((([artist_topic].[topic_id])=[topic].[topic_id])
And (([artist_topic].[artist_id])=[artist].[artist_id]) And
(([artist_category].[category_id])=[category].[category_id]) And
(([artist_category].[artist_id])=[artist].[artist_id]))"
oRS.Open strSQL, objConn
else
str1SQL = "SELECT topic_id FROM topic WHERE topic_name ='" & topicname &
"'"
oRS1.Open str1SQL, objConn
str2SQL = "SELECT category_id FROM category WHERE category_name ='" &
categoryname & "'"
oRS2.Open str2SQL, objConn
strSQL = "SELECT DISTINCT [artist].[artist_name] AS artistname,
[artist].[artist_id] AS artistid, [topic].[topic_id] AS topicid,
[category].[category_name]"
strSQL = strSQL & " FROM category INNER JOIN ((topic INNER JOIN (artist
INNER JOIN artist_topic ON [artist].[artist_id]=[artist_topic].[artist_id])
ON [topic].[topic_id]=[artist_topic].[topic_id]) INNER JOIN artist_category
ON [artist].[artist_id]=[artist_category].[artist_id]) ON
[category].[category_id]=[artist_category].[category_id]"
strSQL = strSQL & " WHERE ((([artist_topic].[topic_id])=" &
oRS1("topic_id") & ") And
(([artist_topic].[artist_id])=[artist].[artist_id]) And
(([artist_category].[category_id])=" & oRS2("category_id") & ") And
(([artist_category].[artist_id])=[artist].[artist_id]))"
strSQL = strSQL & " ORDER BY [artist].[artist_id]"
oRS.Open strSQL, objConn
oRS1.close
Set oRS1 = Nothing
oRS2.close
Set oRS2 = Nothing
end if
%><html>
<head>
<title>Shoot Search Results</title>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
ns = (document.layers)? true:false
ie = (document.all)? true:false
</SCRIPT>
</head>
<body onload="(ie)? parent.loadSourceFinish() : loadSourceFinish();">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr valign=top>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
<td class=copyResults width=25%><%
mycount = 1
If NOT oRS.BOF Then
Do while not oRS.EOF
if mycount > 0 and mycount <8 Then
response.write "<a href='portfolio_personal.asp?tonic-id=" &
oRS("artistid") & "&tonic-topicid=" & oRS("topicid") & "'>" &
oRS("artistname") & "</a><br>"
End if
mycount =mycount + 1
oRS.movenext
loop
oRS.movefirst
Else
response.write "<font color='#ff66cc'>sorry no records found</font>"
End If
%></td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
<td class=copyResults width=25%><%
mycount = 1
If NOT oRS.BOF Then
Do while not oRS.EOF
if mycount > 7 and mycount <15 Then
response.write "<a href='portfolio_personal.asp?tonic-id=" &
oRS("artistid") & "&tonic-topicid=" & oRS("topicid") & "'>" &
oRS("artistname") & "</a><br>"
End if
mycount =mycount + 1
oRS.movenext
loop
oRS.movefirst
Else
response.write " "
End If
%></td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
<td class=copyResults width=25%><%
mycount = 1
If NOT oRS.BOF Then
Do while not oRS.EOF
if mycount > 14 and mycount <22 Then
response.write "<a href='portfolio_personal.asp?tonic-id=" &
oRS("artistid") & "&tonic-topicid=" & oRS("topicid") & "'>" &
oRS("artistname") & "</a><br>"
End if
mycount =mycount + 1
oRS.movenext
loop
oRS.movefirst
Else
response.write " "
End If
%></td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
<td class=copyResults width=25%><%
mycount = 1
If NOT oRS.BOF Then
Do while not oRS.EOF
if mycount > 21 and mycount <28 Then
response.write "<a href='portfolio_personal.asp?tonic-id=" &
oRS("artistid") & "&tonic-topicid=" & oRS("topicid") & "'>" &
oRS("artistname") & "</a><br>"
End if
mycount =mycount + 1
oRS.movenext
loop
oRS.movefirst
Else
response.write " "
End If
%></td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
</tr>
</table>
</body>
</html>
<%
oRS.close
Set oRS = Nothing
objConn.close
Set objConn = Nothing
%>
_____________________
Marios Adamantopoulos
Web Developer
Tonic Design Limited
Studio 2, Church Studios
Camden Park Road
London NW1 9AY
Tel +44 (0)20 7691 2227
Fax +44 (0)20 7691 2228
Mob +44(0)7904 221 663
www.tonicdesign.co.uk
............................................................................
....................................
Opinions, conclusions and other information in this message
that do not relate to the official business of Tonic Design Ltd
shall be understood as neither given nor endorsed by them.
............................................................................
....................................
-----Original Message-----
From: Owen Mortensen [mailto:ojm@a...]
Sent: 22 March 2001 20:34
To: ASP Databases
Subject: [asp_databases] RE: how?
Do you have the Wrox book _Beginning Active Server Pages 3.0_? Appendix C
has a good summary of all the methods, etc. of a Recordset object. Use the
RecordCount property of a Recordset object (making sure you have the right
kind of cursor type and location -- someone jump in here...) to find out how
many records you have.
Owen
-----Original Message-----
From: Marios Adamantopoulos [mailto:mario@T...]
Sent: Thursday, March 22, 2001 12:58 PM
To: ASP Databases
Subject: [asp_databases] RE: how?
how do you get the count from the recordset?
do I have to put it in the SQL command?
_____________________
Marios Adamantopoulos
Web Developer
Tonic Design Limited
Studio 2, Church Studios
Camden Park Road
London NW1 9AY
Tel +44 (0)20 7691 2227
Fax +44 (0)20 7691 2228
Mob +44(0)7904 221 663
www.tonicdesign.co.uk
............................................................................
....................................
Opinions, conclusions and other information in this message
that do not relate to the official business of Tonic Design Ltd
shall be understood as neither given nor endorsed by them.
............................................................................
....................................
-----Original Message-----
From: Owen Mortensen [ mailto:ojm@a... <mailto:ojm@a...> ]
Sent: 22 March 2001 18:29
To: ASP Databases
Subject: [asp_databases] RE: how?
So get the count from the Recordset to find out how many items there are
total, divide by three, get the whole recordset out into an array and then
index through the array as you go through the table rows.
Owen
-----Original Message-----
From: Marios Adamantopoulos [ mailto:mario@T...
<mailto:mario@T...> ]
Sent: Thursday, March 22, 2001 11:01 AM
To: ASP Databases
Subject: [asp_databases] RE: how?
Thanks all, for your responses,
the thing is that I don't want to scan horizontally...
In the first column I have the following(just for testing though;
I don't want all the results on the first table.
--------------
<%
Do while not oRS.EOF
response.write "<a href='portfolio_personal.asp?tonic-id=" &
oRS("artistid") & "&tonic-topicid=" & oRS("topicid") & "'>" &
oRS("artistname") & "</a><br>"
oRS.movenext
loop
%>
--------------
Here is the table I'm trying to create
--------------
<table>
<tr>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">adrian green</a><br>
<a href="portfolio_personal.html">adrian myers</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">adrian green</a><br>
<a href="portfolio_personal.html">adrian myers</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">emma leon</a><br>
<a href="portfolio_personal.html">glyn roberts</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">adrian green</a><br>
<a href="portfolio_personal.html">adrian myers</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
</tr>
</table>
--------------
_____________________
Marios Adamantopoulos
Web Developer
Tonic Design Limited
Studio 2, Church Studios
Camden Park Road
London NW1 9AY
Tel +44 (0)20 7691 2227
Fax +44 (0)20 7691 2228
Mob +44(0)7904 221 663
www.tonicdesign.co.uk
---
SoftArtisans helps developers build robust, scalable Web applications!
Excel Web reports, charts: http://www.softartisans.com/excelwriter.html
<http://www.softartisans.com/excelwriter.html>
File uploads: http://www.softartisans.com/saf.html
<http://www.softartisans.com/saf.html>
Transactional file management: http://www.softartisans.com/saf1.html
<http://www.softartisans.com/saf1.html>
Scalability: http://www.softartisans.com/saxsession.html
<http://www.softartisans.com/saxsession.html>
ASPstudio value pack: http://www.softartisans.com/aspstudiosuite.html
<http://www.softartisans.com/aspstudiosuite.html>
---
$subst('Email.Unsub')
---
SoftArtisans helps developers build robust, scalable Web applications!
Excel Web reports, charts: http://www.softartisans.com/excelwriter.html
File uploads: http://www.softartisans.com/saf.html
Transactional file management: http://www.softartisans.com/saf1.html
Scalability: http://www.softartisans.com/saxsession.html
ASPstudio value pack: http://www.softartisans.com/aspstudiosuite.html
$subst('Email.Unsub')
---
SoftArtisans helps developers build robust, scalable Web applications!
Excel Web reports, charts: http://www.softartisans.com/excelwriter.html
File uploads: http://www.softartisans.com/saf.html
Transactional file management: http://www.softartisans.com/saf1.html
Scalability: http://www.softartisans.com/saxsession.html
ASPstudio value pack: http://www.softartisans.com/aspstudiosuite.html
$subst('Email.Unsub')
Message #9 by "Ken Schaefer" <ken@a...> on Fri, 23 Mar 2001 11:16:26 +1100
|
|
argh...!!!
Do it this way please!
<%
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open strSQL, objConn, adOpenForwardOnly, adLockReadOnly, adCmdText
If not objRS.EOF then
arrResults = objRS.getRows
End if
objRS.close
Set objRS = nothing
objConn.close
Set objConn = nothing
If isArray(arrResults) then
i = 0
Response.Write("<table>" & vbCrLf)
Do while i <= UBound(arrResults, 2))
Response.Write("<tr>" & vbCrLf)
For j = 1 to 3
If i <= UBound(arrResults, 2) then
Response.Write( _
"<td>" & arrResults(0,i) & "</td>" & vbCrLf)
i = i + 1
End if
Next
Response.Write("</tr>" & vbCrLf)
Next
Else
Response.Write("No Results)
End if
%>
Much simpler
Cheers
Ken
Message #10 by philip.moh@a... on Fri, 23 Mar 2001 09:02:14 +0800
|
|
Ken,
Do you know how to control the scroll bar? I mean can set it on/off in
certain page.
Thanks
Phil
> -----Original Message-----
> From: Ken Schaefer [SMTP:ken@a...]
> Sent: Friday, March 23, 2001 8:16 AM
> To: ASP Databases
> Subject: [asp_databases] RE: how?
>
> argh...!!!
>
> Do it this way please!
>
> <%
> Set objRS = Server.CreateObject("ADODB.Recordset")
> objRS.Open strSQL, objConn, adOpenForwardOnly, adLockReadOnly, adCmdText
>
> If not objRS.EOF then
>
> arrResults = objRS.getRows
>
> End if
>
> objRS.close
> Set objRS = nothing
>
> objConn.close
> Set objConn = nothing
>
> If isArray(arrResults) then
>
> i = 0
> Response.Write("<table>" & vbCrLf)
>
> Do while i <= UBound(arrResults, 2))
>
> Response.Write("<tr>" & vbCrLf)
>
> For j = 1 to 3
>
> If i <= UBound(arrResults, 2) then
>
> Response.Write( _
> "<td>" & arrResults(0,i) & "</td>" & vbCrLf)
>
> i = i + 1
>
> End if
>
> Next
>
> Response.Write("</tr>" & vbCrLf)
>
> Next
>
> Else
>
> Response.Write("No Results)
>
> End if
> %>
>
> Much simpler
>
> Cheers
> Ken
Message #11 by "Craig Flannigan" <ckf@k...> on Fri, 23 Mar 2001 08:12:03 -0000
|
|
objRST.Recordcount
As long as your cursor is dynamic, you can read the counter
by the above command.
-----Original Message-----
From: Marios Adamantopoulos [mailto:mario@T...]
Sent: 22 March 2001 07:58 PM
To: ASP Databases
Subject: [asp_databases] RE: how?
how do you get the count from the recordset?
do I have to put it in the SQL command?
_____________________
Marios Adamantopoulos
Web Developer
Tonic Design Limited
Studio 2, Church Studios
Camden Park Road
London NW1 9AY
Tel +44 (0)20 7691 2227
Fax +44 (0)20 7691 2228
Mob +44(0)7904 221 663
www.tonicdesign.co.uk
............................................................
....................................................
Opinions, conclusions and other information in this message
that do not relate to the official business of Tonic Design
Ltd
shall be understood as neither given nor endorsed by them.
............................................................
....................................................
-----Original Message-----
From: Owen Mortensen [mailto:ojm@a...]
Sent: 22 March 2001 18:29
To: ASP Databases
Subject: [asp_databases] RE: how?
So get the count from the Recordset to find out how many
items there are
total, divide by three, get the whole recordset out into an
array and then
index through the array as you go through the table rows.
Owen
-----Original Message-----
From: Marios Adamantopoulos [mailto:mario@T...]
Sent: Thursday, March 22, 2001 11:01 AM
To: ASP Databases
Subject: [asp_databases] RE: how?
Thanks all, for your responses,
the thing is that I don't want to scan horizontally...
In the first column I have the following(just for testing
though;
I don't want all the results on the first table.
--------------
<%
Do while not oRS.EOF
response.write "<a
href='portfolio_personal.asp?tonic-id=" &
oRS("artistid") & "&tonic-topicid=" & oRS("topicid") & "'>"
&
oRS("artistname") & "</a><br>"
oRS.movenext
loop
%>
--------------
Here is the table I'm trying to create
--------------
<table>
<tr>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">adrian
green</a><br>
<a href="portfolio_personal.html">adrian
myers</a><br>
<a href="portfolio_personal.html">allison
fennel</a><br>
<a href="portfolio_personal.html">caroline
harding</a><br>
<a href="portfolio_personal.html">allison
fennel</a><br>
<a href="portfolio_personal.html">caroline
harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1"
border="0" alt=""></td>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">adrian
green</a><br>
<a href="portfolio_personal.html">adrian
myers</a><br>
<a href="portfolio_personal.html">allison
fennel</a><br>
<a href="portfolio_personal.html">caroline
harding</a><br>
<a href="portfolio_personal.html">allison
fennel</a><br>
<a href="portfolio_personal.html">caroline
harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1"
border="0" alt=""></td>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">emma
leon</a><br>
<a href="portfolio_personal.html">glyn
roberts</a><br>
<a href="portfolio_personal.html">allison
fennel</a><br>
<a href="portfolio_personal.html">caroline
harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1"
border="0" alt=""></td>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">adrian
green</a><br>
<a href="portfolio_personal.html">adrian
myers</a><br>
<a href="portfolio_personal.html">allison
fennel</a><br>
<a href="portfolio_personal.html">caroline
harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1"
border="0" alt=""></td>
</tr>
</table>
Message #12 by Ali Karimi <a97alika@s...> on Fri, 23 Mar 2001 14:05:40 +0100
|
|
Actually, i have to say that you will never get the result that you are
expecting. The code you have posted here will not give you 3 columns at each
row, it will only be 2 columns. You should change the location of "num = num
+ 1" or change the "If num = 2 Then..." to "If num = 3 Then...".
Another thing.... the "If num < 2 then Response.Write "</td>"" should be
changed to "If num < 2 then Response.Write "</tr></table>".
Regards
// Ali
----- Original Message -----
From: "Daniel O'Dorisio" <dodorisio@h...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, March 22, 2001 4:43 PM
Subject: [asp_databases] RE: how?
> ---------------------------------------
> : start table
> : loop until end of data
> : open table row
> : first cell
> : if data returned add it
> : else add a space
> : second cell
> : if data returned add it
> : else add a space
> : third cell
> : if data returned add it
> : else add a space
> : close table row
> : end loop
> : end table
> ----------------------------------------
>
> this will give him an infinite loop... you aren't moving to the next
> record.. and if you did, it would give him this:
>
> ---------------------------------
> artist1 | artist1 | artist1|
> artist2 | artist2 | artist2|
> artist3 | artist3 | artist3|
> artist4 | artist4 | artist4|
> ---------------------------------
>
> here is what I would do:
>
> Dim num
> Dim objrs
> set objrs = Server.Creatobject("ADODB.Recordset")
> objrs.open "SELECT <whatever> FROM <wherever> WHERE <clause>", connstring
>
> Response.Write "<table border=""0"">"
> num = 0
> Do until objrs.eof
> 'open a new row if needed
> If num = 0 then
> Response.Write "<tr>"
> End if
>
> 'write the contents
> Response.Write "<td>" & objrs("value") & "</td>"
>
> 'increment the num
> num = num + 1
>
> 'close the row if needed
> If num = 2 Then
> Response.Write "</tr>"
> 'set num back to 0 to start the process for a new row
> num = 0
> End If
> 'move to the next record. if this isn't done you will get an infinite
> loop:-)
> objrs.MoveNext
> Loop
> ' you might need to do this as well, I'm not sure. I haven't "played"
> ' with the code, so I don't know if it will work great. but depending
> ' on the number of records, the table row wont get closed, so I would
> ' add this:
>
> If num < 2 then Response.Write "</td>"
>
> objrs.close
> set objrs = nothing
>
> this should give you:
>
> ---------------------------------
> artist1 | artist2 | artist3|
> artist4 | artist5 | artist6|
> artist7 | artist8 | artist9|
> artist10 | artist11 | artist12|
> ---------------------------------
> if you want it in the other order (top to bottom, left to right, instead
of
> left to right, top to bottom) let me think on it for a sec:-) and play
some.
>
> Daniel
>
> -----Original Message-----
> From: Gregory_Griffiths@c...
> [mailto:Gregory_Griffiths@c...]
> Sent: Thursday, March 22, 2001 10:06 AM
> To: ASP Databases
> Subject: [asp_databases] RE: how?
>
>
> Try something like
>
> start table
> loop until end of data
> open table row
> first cell
> if data returned add it
> else add a space
> second cell
> if data returned add it
> else add a space
> third cell
> if data returned add it
> else add a space
> close table row
> end loop
> end table
>
> I don't have an ASP ref. handy to give you some samepl code, but I'll
> try to put some together unless someone else gets their first.
>
> -----Original Message-----
> From: mario@T... [mailto:mario@T...]
> Sent: 22 March 2001 14:31
> To: asp_databases@p...
> Cc: mario@T...
> Subject: [asp_databases] how?
>
>
>
>
>
>
> Hi all,
>
> since I am a beginner in ASP I can simple questions right?
>
> I have about 20 artists in my database and what I need to do is to
> output them on my page
>
> in the following way
>
> ---------------------------------
> artist1 | artist5 | artist9 |
> artist2 | artist6 | artist10|
> artist3 | artist7 | artist11|
> artist4 | artist8 | artist12|
> ---------------------------------
>
> that list is going to change though. If I choose a specific topic
> I might get only 5 artists back, or 2
>
> Anyone can help?
>
> _____________________
> Marios Adamantopoulos
> Web Developer
>
> Tonic Design Limited
> Studio 2, Church Studios
> Camden Park Road
> London NW1 9AY
>
> Tel +44 (0)20 7691 2227
> Fax +44 (0)20 7691 2228
> Mob +44(0)7904 221 663
>
> www.tonicdesign.co.uk
Message #13 by Marios Adamantopoulos <mario@T...> on Fri, 23 Mar 2001 14:43:36 -0000
|
|
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C0B3A7.A9DE12AC
Content-Type: text/plain;
charset="iso-8859-1"
Finally I made it...
Thanks all for your help, and since you all helped, here is the final code.
I don't know if the techniques I used are good or not, but I think for a
first timer
in a space of two weeks to finish a web site and content management tool,
I did ok...
Any appreciate any comments, but go easy...
Thanks again
Mario
Here is that page
----------------------------------------------
<%
dim objConn
dim strSQL
dim str2SQL
dim topicname
dim categoryname
dim mycount
topicname= Request.QueryString("TOPIC")
categoryname= Request.QueryString("CATEGORY")
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "DSN=somedatabase"
set oRS=server.CreateObject("ADODB.recordset")
set oRS1=server.CreateObject("ADODB.recordset")
set oRS2=server.CreateObject("ADODB.recordset")
if topicname="everybody" and categoryname <> "allfields" then
str2SQL = "SELECT category_id FROM category WHERE category_name ='" &
categoryname & "'"
oRS2.Open str2SQL, objConn
strSQL = "SELECT DISTINCT [artist].[artist_name] AS artistname,
[artist].[artist_id] AS artistid, [topic].[topic_id] AS topicid,
[category].[category_name]"
strSQL = strSQL & " FROM category INNER JOIN ((topic INNER JOIN (artist
INNER JOIN artist_topic ON [artist].[artist_id]=[artist_topic].[artist_id])
ON [topic].[topic_id]=[artist_topic].[topic_id]) INNER JOIN artist_category
ON [artist].[artist_id]=[artist_category].[artist_id]) ON
[category].[category_id]=[artist_category].[category_id]"
strSQL = strSQL & " WHERE ((([artist_topic].[topic_id])=[topic].[topic_id])
And (([artist_topic].[artist_id])=[artist].[artist_id]) And
(([artist_category].[category_id])=" & oRS2("category_id") & ") And
(([artist_category].[artist_id])=[artist].[artist_id]))"
strSQL = strSQL & " ORDER BY [artist].[artist_id]"
oRS.Open strSQL, objConn
oRS2.close
Set oRS2 = Nothing
elseif categoryname = "allfields" and topicname <> "everybody" then
str1SQL = "SELECT topic_id FROM topic WHERE topic_name ='" & topicname &
"'"
oRS1.Open str1SQL, objConn
strSQL = "SELECT [artist].[artist_id] AS artistid, [artist].[artist_name]
AS artistname, [topic].[topic_name], [topic].[topic_id] AS topicid"
strSQL = strSQL & " FROM topic INNER JOIN (artist INNER JOIN artist_topic
ON [artist].[artist_id]=[artist_topic].[artist_id]) ON
[topic].[topic_id]=[artist_topic].[topic_id]"
strSQL = strSQL & " WHERE ((([artist_topic].[topic_id])=" &
oRS1("topic_id") & ") And
(([artist_topic].[artist_id])=[artist].[artist_id]))"
strSQL = strSQL & " ORDER BY [artist].[artist_id]"
oRS.Open strSQL, objConn
oRS1.close
Set oRS1 = Nothing
elseif categoryname = "allfields" and topicname = "everybody" then
strSQL = "SELECT DISTINCT [artist].[artist_name] AS artistname,
[artist].[artist_id] AS artistid, [topic].[topic_id] AS topicid"
strSQL = strSQL & " FROM category INNER JOIN ((topic INNER JOIN (artist
INNER JOIN artist_topic ON [artist].[artist_id]=[artist_topic].[artist_id])
ON [topic].[topic_id]=[artist_topic].[topic_id]) INNER JOIN artist_category
ON [artist].[artist_id]=[artist_category].[artist_id]) ON
[category].[category_id]=[artist_category].[category_id]"
strSQL = strSQL & " WHERE ((([artist_topic].[topic_id])=[topic].[topic_id])
And (([artist_topic].[artist_id])=[artist].[artist_id]) And
(([artist_category].[category_id])=[category].[category_id]) And
(([artist_category].[artist_id])=[artist].[artist_id]))"
oRS.Open strSQL, objConn
else
str1SQL = "SELECT topic_id FROM topic WHERE topic_name ='" & topicname &
"'"
oRS1.Open str1SQL, objConn
str2SQL = "SELECT category_id FROM category WHERE category_name ='" &
categoryname & "'"
oRS2.Open str2SQL, objConn
strSQL = "SELECT DISTINCT [artist].[artist_name] AS artistname,
[artist].[artist_id] AS artistid, [topic].[topic_id] AS topicid,
[category].[category_name]"
strSQL = strSQL & " FROM category INNER JOIN ((topic INNER JOIN (artist
INNER JOIN artist_topic ON [artist].[artist_id]=[artist_topic].[artist_id])
ON [topic].[topic_id]=[artist_topic].[topic_id]) INNER JOIN artist_category
ON [artist].[artist_id]=[artist_category].[artist_id]) ON
[category].[category_id]=[artist_category].[category_id]"
strSQL = strSQL & " WHERE ((([artist_topic].[topic_id])=" &
oRS1("topic_id") & ") And
(([artist_topic].[artist_id])=[artist].[artist_id]) And
(([artist_category].[category_id])=" & oRS2("category_id") & ") And
(([artist_category].[artist_id])=[artist].[artist_id]))"
strSQL = strSQL & " ORDER BY [artist].[artist_id]"
oRS.Open strSQL, objConn
oRS1.close
Set oRS1 = Nothing
oRS2.close
Set oRS2 = Nothing
end if
%><html>
<head>
<title>Shoot Search Results</title>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
ns = (document.layers)? true:false
ie = (document.all)? true:false
</SCRIPT>
</head>
<body onload="(ie)? parent.loadSourceFinish() : loadSourceFinish();">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr valign=top>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
<td class=copyResults width=25%><%
mycount = 1
If NOT oRS.BOF Then
Do while not oRS.EOF
if mycount > 0 and mycount <8 Then
response.write "<a href='portfolio_personal.asp?tonic-id=" &
oRS("artistid") & "&tonic-topicid=" & oRS("topicid") & "'>" &
oRS("artistname") & "</a><br>"
End if
mycount =mycount + 1
oRS.movenext
loop
oRS.movefirst
Else
response.write "<font color='#ff66cc'>sorry no records found</font>"
End If
%></td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
<td class=copyResults width=25%><%
mycount = 1
If NOT oRS.BOF Then
Do while not oRS.EOF
if mycount > 7 and mycount <15 Then
response.write "<a href='portfolio_personal.asp?tonic-id=" &
oRS("artistid") & "&tonic-topicid=" & oRS("topicid") & "'>" &
oRS("artistname") & "</a><br>"
End if
mycount =mycount + 1
oRS.movenext
loop
oRS.movefirst
Else
response.write " "
End If
%></td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
<td class=copyResults width=25%><%
mycount = 1
If NOT oRS.BOF Then
Do while not oRS.EOF
if mycount > 14 and mycount <22 Then
response.write "<a href='portfolio_personal.asp?tonic-id=" &
oRS("artistid") & "&tonic-topicid=" & oRS("topicid") & "'>" &
oRS("artistname") & "</a><br>"
End if
mycount =mycount + 1
oRS.movenext
loop
oRS.movefirst
Else
response.write " "
End If
%></td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
<td class=copyResults width=25%><%
mycount = 1
If NOT oRS.BOF Then
Do while not oRS.EOF
if mycount > 21 and mycount <28 Then
response.write "<a href='portfolio_personal.asp?tonic-id=" &
oRS("artistid") & "&tonic-topicid=" & oRS("topicid") & "'>" &
oRS("artistname") & "</a><br>"
End if
mycount =mycount + 1
oRS.movenext
loop
oRS.movefirst
Else
response.write " "
End If
%></td>
<td><img src="img/px.gif" width="15" height="1" border="0" alt=""></td>
</tr>
</table>
</body>
</html>
<%
oRS.close
Set oRS = Nothing
objConn.close
Set objConn = Nothing
%>
Message #14 by "Daniel O'Dorisio" <dodorisio@h...> on Fri, 23 Mar 2001 10:10:11 -0500
|
|
yup.. my bad, i was thinking 0, 1, and 2 which is 3 numbers. i when i really
need 4 numbers... sorry about that. thnks for catching me:-) also i spelled
createObject wrong... forgot an "e" :-) oh well. like i said.. i didnt
actually run the code before i sent it. so much for trying to help.. eh? :-)
latah
Daniel
-----Original Message-----
From: Ali Karimi [mailto:a97alika@s...]
Sent: Friday, March 23, 2001 8:06 AM
To: ASP Databases
Subject: [asp_databases] RE: how?
Actually, i have to say that you will never get the result that you are
expecting. The code you have posted here will not give you 3 columns at each
row, it will only be 2 columns. You should change the location of "num = num
+ 1" or change the "If num = 2 Then..." to "If num = 3 Then...".
Another thing.... the "If num < 2 then Response.Write "</td>"" should be
changed to "If num < 2 then Response.Write "</tr></table>".
Regards
// Ali
----- Original Message -----
From: "Daniel O'Dorisio" <dodorisio@h...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, March 22, 2001 4:43 PM
Subject: [asp_databases] RE: how?
> ---------------------------------------
> : start table
> : loop until end of data
> : open table row
> : first cell
> : if data returned add it
> : else add a space
> : second cell
> : if data returned add it
> : else add a space
> : third cell
> : if data returned add it
> : else add a space
> : close table row
> : end loop
> : end table
> ----------------------------------------
>
> this will give him an infinite loop... you aren't moving to the next
> record.. and if you did, it would give him this:
>
> ---------------------------------
> artist1 | artist1 | artist1|
> artist2 | artist2 | artist2|
> artist3 | artist3 | artist3|
> artist4 | artist4 | artist4|
> ---------------------------------
>
> here is what I would do:
>
> Dim num
> Dim objrs
> set objrs = Server.Creatobject("ADODB.Recordset")
> objrs.open "SELECT <whatever> FROM <wherever> WHERE <clause>", connstring
>
> Response.Write "<table border=""0"">"
> num = 0
> Do until objrs.eof
> 'open a new row if needed
> If num = 0 then
> Response.Write "<tr>"
> End if
>
> 'write the contents
> Response.Write "<td>" & objrs("value") & "</td>"
>
> 'increment the num
> num = num + 1
>
> 'close the row if needed
> If num = 2 Then
> Response.Write "</tr>"
> 'set num back to 0 to start the process for a new row
> num = 0
> End If
> 'move to the next record. if this isn't done you will get an infinite
> loop:-)
> objrs.MoveNext
> Loop
> ' you might need to do this as well, I'm not sure. I haven't "played"
> ' with the code, so I don't know if it will work great. but depending
> ' on the number of records, the table row wont get closed, so I would
> ' add this:
>
> If num < 2 then Response.Write "</td>"
>
> objrs.close
> set objrs = nothing
>
> this should give you:
>
> ---------------------------------
> artist1 | artist2 | artist3|
> artist4 | artist5 | artist6|
> artist7 | artist8 | artist9|
> artist10 | artist11 | artist12|
> ---------------------------------
> if you want it in the other order (top to bottom, left to right, instead
of
> left to right, top to bottom) let me think on it for a sec:-) and play
some.
>
> Daniel
>
> -----Original Message-----
> From: Gregory_Griffiths@c...
> [mailto:Gregory_Griffiths@c...]
> Sent: Thursday, March 22, 2001 10:06 AM
> To: ASP Databases
> Subject: [asp_databases] RE: how?
>
>
> Try something like
>
> start table
> loop until end of data
> open table row
> first cell
> if data returned add it
> else add a space
> second cell
> if data returned add it
> else add a space
> third cell
> if data returned add it
> else add a space
> close table row
> end loop
> end table
>
> I don't have an ASP ref. handy to give you some samepl code, but I'll
> try to put some together unless someone else gets their first.
>
> -----Original Message-----
> From: mario@T... [mailto:mario@T...]
> Sent: 22 March 2001 14:31
> To: asp_databases@p...
> Cc: mario@T...
> Subject: [asp_databases] how?
>
>
>
>
>
>
> Hi all,
>
> since I am a beginner in ASP I can simple questions right?
>
> I have about 20 artists in my database and what I need to do is to
> output them on my page
>
> in the following way
>
> ---------------------------------
> artist1 | artist5 | artist9 |
> artist2 | artist6 | artist10|
> artist3 | artist7 | artist11|
> artist4 | artist8 | artist12|
> ---------------------------------
>
> that list is going to change though. If I choose a specific topic
> I might get only 5 artists back, or 2
>
> Anyone can help?
>
> _____________________
> Marios Adamantopoulos
> Web Developer
>
> Tonic Design Limited
> Studio 2, Church Studios
> Camden Park Road
> London NW1 9AY
>
> Tel +44 (0)20 7691 2227
> Fax +44 (0)20 7691 2228
> Mob +44(0)7904 221 663
>
> www.tonicdesign.co.uk
Message #15 by "Owen Mortensen" <ojm@a...> on Thu, 22 Mar 2001 13:33:36 -0700
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_0026_01C0B2D4.B2637FD0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
RE: [asp_databases] RE: how?Do you have the Wrox book _Beginning Active
Server Pages 3.0_? Appendix C has a good summary of all the methods, etc.
of a Recordset object. Use the RecordCount property of a Recordset object
(making sure you have the right kind of cursor type and location -- someone
jump in here...) to find out how many records you have.
Owen
-----Original Message-----
From: Marios Adamantopoulos [mailto:mario@T...]
Sent: Thursday, March 22, 2001 12:58 PM
To: ASP Databases
Subject: [asp_databases] RE: how?
how do you get the count from the recordset?
do I have to put it in the SQL command?
_____________________
Marios Adamantopoulos
Web Developer
Tonic Design Limited
Studio 2, Church Studios
Camden Park Road
London NW1 9AY
Tel +44 (0)20 7691 2227
Fax +44 (0)20 7691 2228
Mob +44(0)7904 221 663
www.tonicdesign.co.uk
............................................................................
....................................
Opinions, conclusions and other information in this message
that do not relate to the official business of Tonic Design Ltd
shall be understood as neither given nor endorsed by them.
............................................................................
....................................
-----Original Message-----
From: Owen Mortensen [mailto:ojm@a...]
Sent: 22 March 2001 18:29
To: ASP Databases
Subject: [asp_databases] RE: how?
So get the count from the Recordset to find out how many items there are
total, divide by three, get the whole recordset out into an array and then
index through the array as you go through the table rows.
Owen
-----Original Message-----
From: Marios Adamantopoulos [mailto:mario@T...]
Sent: Thursday, March 22, 2001 11:01 AM
To: ASP Databases
Subject: [asp_databases] RE: how?
Thanks all, for your responses,
the thing is that I don't want to scan horizontally...
In the first column I have the following(just for testing though;
I don't want all the results on the first table.
--------------
<%
Do while not oRS.EOF
response.write "<a href='portfolio_personal.asp?tonic-id=" &
oRS("artistid") & "&tonic-topicid=" & oRS("topicid") & "'>" &
oRS("artistname") & "</a><br>"
oRS.movenext
loop
%>
--------------
Here is the table I'm trying to create
--------------
<table>
<tr>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">adrian green</a><br>
<a href="portfolio_personal.html">adrian myers</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0"
alt=""></td>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">adrian green</a><br>
<a href="portfolio_personal.html">adrian myers</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0"
alt=""></td>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">emma leon</a><br>
<a href="portfolio_personal.html">glyn roberts</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0"
alt=""></td>
<td class=copyResults width=25%>
<a href="portfolio_personal.html">adrian green</a><br>
<a href="portfolio_personal.html">adrian myers</a><br>
<a href="portfolio_personal.html">allison fennel</a><br>
<a href="portfolio_personal.html">caroline harding</a><br>
</td>
<td><img src="img/px.gif" width="15" height="1" border="0"
alt=""></td>
</tr>
</table>
--------------
_____________________
Marios Adamantopoulos
Web Developer
Tonic Design Limited
Studio 2, Church Studios
Camden Park Road
London NW1 9AY
Tel +44 (0)20 7691 2227
Fax +44 (0)20 7691 2228
Mob +44(0)7904 221 663
www.tonicdesign.co.uk
---
SoftArtisans helps developers build robust, scalable Web applications!
Excel Web reports, charts: http://www.softartisans.com/excelwriter.html
File uploads: http://www.softartisans.com/saf.html
Transactional file management: http://www.softartisans.com/saf1.html
Scalability: http://www.softartisans.com/saxsession.html
ASPstudio value pack: http://www.softartisans.com/aspstudiosuite.html
$subst('Email.Unsub')
---
SoftArtisans helps developers build robust, scalable Web applications!
Excel Web reports, charts: http://www.softartisans.com/excelwriter.html
File uploads: http://www.softartisans.com/saf.html
Transactional file management: http://www.softartisans.com/saf1.html
Scalability: http://www.softartisans.com/saxsession.html
ASPstudio value pack: http://www.softartisans.com/aspstudiosuite.html
$subst('Email.Unsub')
---
SoftArtisans helps developers build robust, scalable Web applications!
Excel Web reports, charts: http://www.softartisans.com/excelwriter.html
File uploads: http://www.softartisans.com/saf.html
Transactional file management: http://www.softartisans.com/saf1.html
Scalability: http://www.softartisans.com/saxsession.html
ASPstudio value pack: http://www.softartisans.com/aspstudiosuite.html
|
|
 |