Hello all,
I have a table that has data about the t-shirts i sell. My goal is to display the colors that are available in a specific way on my asp page: Shirt
I have been playing around for hours with this and need a 2nd opinion.
I am using the following query to get the data: -
set color2RecordSet = Server.createObject("ADODB.RecordSet")
-
color2Query = "SELECT DISTINCT product_shirts_colors_sizes.color, product_shirts_colors_sizes.hex, product_shirts_colors_sizes.size, product_shirts_colors_sizes.size FROM product_shirts_colors_sizes WHERE (((product_shirts_colors_sizes.size)='Youth Large' Or (product_shirts_colors_sizes.size)='Adult Large') AND ((product_shirts_colors_sizes.product_id)=" & Request.QueryString("product_id") & "))"
-
color2RecordSet.Open color2Query, dbConn, adOpenStatic, adLockReadOnly, adCmdText
-
-
And the following to display it: -
<% while not color2RecordSet.EOF %>
-
<% if color2RecordSet.fields("size") = "Youth Large" then %>
-
<div style="padding:2px; padding-left:20px; height:30px; width:180px">
-
<div style="height:30px; width:30px; float:left; background-color:#<%= color2RecordSet.fields("hex")%>"></div>
-
<div style="height:25px; padding-left:10px; padding-top:5px; float:right; width:140px; color:#FF0000" ><%= color2RecordSet.fields("color")%></div>
-
</div>
-
<% else %>
-
<div style="padding:2px; padding-left:20px; height:30px; width:180px">
-
<div style="height:30px; width:30px; float:left; background-color:#<%= color2RecordSet.fields("hex")%>"></div>
-
<div style="height:25px; padding-left:10px; padding-top:5px; float:right; width:140px" ><%= color2RecordSet.fields("color")%></div>
-
</div>
-
<% end if%>
-
<% color2RecordSet.movenext %>
-
<% wend %>
-
The problem is that not all colors are available in youth as seen in this image:
What i am trying to accomplish is pulling distinct colors and if it has youth sizes then display in red. If it dose not have youth sizes the display in black.
I hope i have explained enough... if not i can supply more info.
Thanks in advance
4 1293
I am using the following query to get the data: -
set color2RecordSet = Server.createObject("ADODB.RecordSet")
-
color2Query = "SELECT DISTINCT product_shirts_colors_sizes.color, product_shirts_colors_sizes.hex, product_shirts_colors_sizes.size, product_shirts_colors_sizes.size FROM product_shirts_colors_sizes WHERE (((product_shirts_colors_sizes.size)='Youth Large' Or (product_shirts_colors_sizes.size)='Adult Large') AND ((product_shirts_colors_sizes.product_id)=" & Request.QueryString("product_id") & "))"
-
color2RecordSet.Open color2Query, dbConn, adOpenStatic, adLockReadOnly, adCmdText
-
-
When you are only pulling up info from one table, it is OK to shorten the name of the field to just the name of the field, you don't have to say tabelName.fieldName, just say fieldName: - color2Query = "SELECT DISTINCT color, hex, size FROM product_shirts_colors_sizes WHERE (((size)='Youth Large' Or (size)='Adult Large') AND ((product_id)=" & Request.QueryString("product_id") & "))"
I know, it's a little thing, but I figure it helps, right?
And the following to display it:
So you are currently pulling up all the records where size equals "Youth Large" or "Adult Large", right? If the record you are displaying is "adult" then you print in black and if it is "youth" then you print in red. From the link it looks like this is working. Is it not?
Jared
So you are currently pulling up all the records where size equals "Youth Large" or "Adult Large", right? If the record you are displaying is "adult" then you print in black and if it is "youth" then you print in red. From the link it looks like this is working. Is it not?
Jared
Thanks for the reply Jared.
About the query, i was letting Access build it and you know how it loves to change the query to be like that with all the "{{[((" and stuff.....
It does display the query correctly. What i want to show (if possible to do in the query) is:
1) pull the data
2) If "youth" and "adult" show up for the same "color" then display in red
3) else -- if only "adult" then display in black
Thanks for your help
Jason
Jason,
Are the only two possibilities that it is 1- only available in adult or 2- available in both adult or youth?
If that is right, I would add to the end of the query: " ORDER BY color ASC, size DESC", then when I loop through the records if the record is adult, I display in black and continue. If the record is youth, I display in red and skip the next record (it will be the same, but in adult) before I continue. Does this make sense? It might look something like this - do until RS.eof
-
if rs("size") = "Adult Large" then
-
'display in black, whatever your code looked like here
-
else
-
'display in red
-
RS.movenext
-
end if
-
-
'whatever else you do per record
-
RS.movenext
-
loop
Let me know if this helps.
Jared
thanks that worked like a charm. Check out the page now.
Now onto the next thing.......
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Sean C. |
last post by:
Helpful folks,
Most of my previous experience with DB2 was on s390 mainframe systems
and the optimizer on this platform always seemed very predictable and
consistent. Since moving to a WinNT/UDB...
|
by: Andy Davis |
last post by:
I have set up a mail merge document in Word 2003 which gets its data from my
Access 2000 database. I want to set up a button on a form that:
1. runs the query to provide the dat for the merge...
|
by: Justin Fancy |
last post by:
Hi everyone,
I need some help. I'm placing text files into a created database using
vb.Net. The problem is that, i need two seperate sql statements to add
both files because they are in...
|
by: bhcob1 |
last post by:
Hi, Whenever I delete a record my command button, the record deletes, a list displaying all records is updated and then a message box appears:
Microsoft Access can't find the field 'I' referred to...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |