If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Dropdown Not Populating Correctly

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-09-06, 06:11
s4u s4u is offline
Registered User
 
Join Date: May 2006
Posts: 2
Dropdown Not Populating Correctly

Hi All,

I'm joining two tables. A product table and an options table. The options table has a column for different sizes for each product. I'm trying to populate a web form dropdown with the sizes. But the dropdown will only display the first size and repeat that first size. So if I have small, medium, and large, the dropdown will only have "small" 3 times.

Product Table
--------------
ID | Name | Description
1 widget the best product

Options Table
-------------
ID | Size | Inventory
1 small 5
1 medium 1
1 large 2


rs.Source = "SELECT P.id, P.name, P.description, O.id, O.size, O.Inventory FROM Product LEFT JOIN Options ON P.id = O.id AND O.id = '" & QueryStringID & "' WHERE P.id = '" & QueryStringID & "'ORDER BY P.id ASC"

Dim strDropList
While NOT rs.EOF
strDropList = strDropList & "<option value='" & strSize1 & "'>" & strSize1 & "</option>"
rs.MoveNext
Wend

Response.Write "<p><select size='1' name='drop'>"
Response.Write strDropList
Response.Write "</select></p>"

Let me know if you need any more info. Thanks.
Reply With Quote
  #2 (permalink)  
Old 05-09-06, 07:45
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
in your query, you are joining the tables on P.id = O.id

therefore if you specify P.id equal to some QueryStringID in the WHERE clause, then you do not also have to make O.id equal to the same QueryStringID, because it's gonna only ever be equal to P.id

as far as why you're displaying only one size, that's a problem with your script, not mysql, so i'm going to move that thread over to the asp forum (i hope that's what that "movenext" language is)
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 05-10-06, 01:13
s4u s4u is offline
Registered User
 
Join Date: May 2006
Posts: 2
Oops, the Where clause was used just to get the table to populate with only those 3 rows matched with the ID. Just for me to see it visually. But the query without the Where clause is my normal query.

I've used the same query on Oracle and it worked ok. Yes, ASP is used to write out the dropdowns. But is my "query" incorrect for mysql? Sorry, I thought that would make it a mysql-related question.

And I am a bit of a noob. So please be kind


Quote:
Originally Posted by r937
in your query, you are joining the tables on P.id = O.id

therefore if you specify P.id equal to some QueryStringID in the WHERE clause, then you do not also have to make O.id equal to the same QueryStringID, because it's gonna only ever be equal to P.id

as far as why you're displaying only one size, that's a problem with your script, not mysql, so i'm going to move that thread over to the asp forum (i hope that's what that "movenext" language is)
Reply With Quote
  #4 (permalink)  
Old 05-10-06, 06:18
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
your query is fine
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On