Populating drop down box from TWO tables?

Results 1 to 3 of 3

Thread: Populating drop down box from TWO tables?

  1. #1
    Join Date
    Dec 1969

    Default Populating drop down box from TWO tables?

    I don&#039t understand why this isn&#039t working. I am trying to populate a drop down box from two different tables. It only pulls from one.<BR><BR><BR>&#060;form ACTION="editactivity2.asp" method="post" id=form1 name=form1&#062;<BR> <BR>&#060;SELECT id=select2 name="username"&#062;<BR>&#060;OPTION value="" selected&#062;--Make a Selection--&#060;/OPTION&#062;<BR><BR>&#060;%<BR>Dim sqldetails<BR>sqldetails = "SELECT SP.username, SP.hfirstname, " & _<BR>"SP.hlastname, BP.username, " & _<BR>"BP.hfirstname, BP.hlastname " & _<BR>"FROM sellerclientprofile SP, buyerclientprofile BP" <BR> <BR>Dim Con, RS<BR>Set Con = Server.CreateObject("ADODB.Connection")<BR>Con.Ope n ("tng")<BR>Set RS = Server.CreateObject("ADODB.Recordset")<BR>RS.Open sqldetails, con<BR>WHILE NOT RS.EOF<BR>%&#062;<BR><BR>&#060;OPTION value="&#060;%=RS("username")%&#062;"&#062;&#060;% =RS("hfirstname")%&#062;&nbsp;&#060;%=RS("hlastnam e")%&#062;&#060;/OPTION&#062;<BR><BR>&#060;%<BR>RS.MoveNext<BR>%&#0 62; <BR><BR>&#060;/SELECT&#062;<BR><BR>&#060;INPUT type="submit" value="Submit" id=submit1 name=submit1&#062;<BR><BR>&#060;%WEND%&#062;

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default Where is the where..you know where??

    First of all dont you need a where condition? <BR><BR>Are you selecting ALL the records in both the tables??<BR><BR>Wont there be a problem since you have two colmu having the same name. Try giving an alias and see if it works<BR><BR>SELECT SP.username sUsername, SP.hfirstname SFname,SP.hlastname SLnme, BP.username bUsername,BP.hfirstname BFname, BP.hlastname BLname FROM sellerclientprofile SP, buyerclientprofile BP" <BR><BR>then get the values with their alias <BR><BR><BR>WOAH i just realised what you are trying to do get all the palues and populate the drop down in one loop and have ALL the names from BOTH tables in the same drop down....hmmmm....<BR><BR>Wow i really have never done anything like this and to be honest this is the first time i haev ever SEEN anything like this. My columns always have different names so i guess this has never crossed my path....i really have no clue what to do...sorry but one workaround is 2 loops <BR><BR>populate with one then the famour movefirst and then again or in one loop where you do a move first at the eof<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: Populating drop down box from TWO tables?

    Can u please post the html-code the client is getting?
    Wiki Vaporizer
    Last edited by Jay; 04-16-2011 at 01:44 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts