|
 |
access_asp thread: View Products by Manufacturer and Category
Message #1 by "Lori Bannon" <lori@s...> on Mon, 30 Dec 2002 22:35:57
|
|
So far with my little template fun (go here if you want to view the
template: http://www.skyesweb.com/template/index.asp) I have it set up so
that when a user selects by manufacturer the productDisplay.asp page will
only display those records that have that manufacturer name.
Code:
<%
strSQL = "Select * from tblList, tblManu"
strSQL = strSQL & " Where tblList.fldName=tblManu.fldManuName"
If fieldManuName <> "" Then
strSQL = strSQL & " AND tblList.fldName='" & fieldManuName & "'"
End If
'Set connection object
set conn = server.createobject("adodb.connection")
conn.open strconn
'Use the execute method of the connection object the insert the record
SET oRs = conn.execute(strSQL)
While Not oRs.EOF
%>
<tr>
<td><% strImagePath = oRs.Fields("fldImagePath")
Response.Write("<img src=" & strImagePath & ">") %></td>
<td class="colorHeader"><% = oRs.Fields("fldName") %></td>
<td class="colorHeader"><% = oRs.Fields("fldDesc") %></td>
<td class="colorHeader"><% = oRs.Fields("fldPrice") %></td>
</tr>
<% oRs.MoveNext
wend%>
<%
conn.close
set conn = nothing
%>
Now I want to get a little more complicated and seperate the different
categories as well on the same productDisplay.asp page:
For Instance:
Manufacturers Name
Amplifiers
Image Name Description Price
Preamplifiers
Image Name Description Price
Speakers
Image Name Description Price
and so on...
I was hoping that a simple:
If oRs.Fields("fldCategory") = "Amplifiers" then
write those records that have that category
would work but no such luck. Maybe i'm going about it the wrong way.
Any suggestions????
thanks ahead of time
Lori
Message #2 by "Paulo Fernandes" <paulofernandes@c...> on Mon, 30 Dec 2002 22:45:01 -0000
|
|
Well, I'd start by ordering your SQL string by the field category:
Select * from whatever order by fldCategory
Then, if you want to apply some special formating, just compare the current
fldCategory field value (inside the loop) with the previous one:
dim temp
with oRs
do while not .eof
if .Fields("fldCategory") <> temp then
' different category...do something different
else
' still the same category.. just do the same thing
temp = .Fields("fldCategory")
.movenext
loop
end with
In the first record, it'll compare the fldCategory to an empty string,
applying the new formatting.
The second record, however, will be compared to the first one, thus enabling
the routine to "know" wheter it is still in the same category or not.
HTH
Paulo Fernandes
Consernet, Lda.
www.consernet.com
Telefone: +xxx xxx xxx xxx
Telemóvel: +xxx xxx xxx xxx
Fax: +xxx xxx xxx xxx
----------------------------
Este e-mail é confidencial. Se você não é o destinatário pretendido deste
e-mail,não deverá usar qualquer informação nele contida. Se recebeu este
e-mail por erro, envie-o para administrador@c..., apagando-o de
seguida. Obrigado.
This email is confidential. If you are not the intended recipient, you must
not disclose or use the information contained in it. If you have received
this mail in error, please forward it to administrador@c... and
delete the document. Thank you.
-----Mensagem original-----
De: Lori Bannon [mailto:lori@s...]
Enviada: segunda-feira, 30 de Dezembro de 2002 22:36
Para: Access ASP
Assunto: [access_asp] View Products by Manufacturer and Category
So far with my little template fun (go here if you want to view the
template: http://www.skyesweb.com/template/index.asp) I have it set up so
that when a user selects by manufacturer the productDisplay.asp page will
only display those records that have that manufacturer name.
Code:
<%
strSQL = "Select * from tblList, tblManu"
strSQL = strSQL & " Where tblList.fldName=tblManu.fldManuName"
If fieldManuName <> "" Then
strSQL = strSQL & " AND tblList.fldName='" & fieldManuName & "'"
End If
'Set connection object
set conn = server.createobject("adodb.connection")
conn.open strconn
'Use the execute method of the connection object the insert the record
SET oRs = conn.execute(strSQL)
While Not oRs.EOF
%>
<tr>
<td><% strImagePath = oRs.Fields("fldImagePath")
Response.Write("<img src=" & strImagePath & ">") %></td>
<td class="colorHeader"><% = oRs.Fields("fldName") %></td>
<td class="colorHeader"><% = oRs.Fields("fldDesc") %></td>
<td class="colorHeader"><% = oRs.Fields("fldPrice") %></td>
</tr>
<% oRs.MoveNext
wend%>
<%
conn.close
set conn = nothing
%>
Now I want to get a little more complicated and seperate the different
categories as well on the same productDisplay.asp page:
For Instance:
Manufacturers Name
Amplifiers
Image Name Description Price
Preamplifiers
Image Name Description Price
Speakers
Image Name Description Price
and so on...
I was hoping that a simple:
If oRs.Fields("fldCategory") = "Amplifiers" then
write those records that have that category
would work but no such luck. Maybe i'm going about it the wrong way.
Any suggestions????
thanks ahead of time
Lori
|
|
 |