SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast joeyramirez's Avatar
    Join Date
    Nov 2011
    Location
    Cabanatuan City, Philippines
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Populate data from table(MySQL) and put it on a combo box

    I need a code that can populate data from a table and put it on a combo box without using a loop.My code looks like this:



    <%
    Dim sql5,rs5
    sql5= "SELECT * FROM tblstatus"
    Set rs5= Server.CreateObject("ADODB.Recordset")
    rs5.Open sql5, Conn, 1,3
    %>
    <select name="cbostatus">
    <%
    While not rs5.EOF
    %>
    <option value="<%=rs5("statusID")%>" selected="<%=rs("sid") %>"><%=rs5("status")%></option>
    <%
    rs5.MoveNext
    Wend

    Set rs5= nothing
    %>
    </select>

  2. #2
    SitePoint Enthusiast joeyramirez's Avatar
    Join Date
    Nov 2011
    Location
    Cabanatuan City, Philippines
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I need a very short code.

  3. #3
    SitePoint Addict
    Join Date
    Apr 2009
    Posts
    357
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Why do you not want to use a loop? Looping is a basic programming construct.
    Doug G
    =====
    "If you ain't the lead dog, the view is always the same - Anon

  4. #4
    SitePoint Enthusiast joeyramirez's Avatar
    Join Date
    Nov 2011
    Location
    Cabanatuan City, Philippines
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I will put this combo box in an edit page. I think the combo box loop will be inside another loop. Is it ok to have a loop inside another loop?

  5. #5
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    How many elements in the combobox loop?

    How many elements in the outer loop?
    Ian Anderson
    www.siteguru.co.uk

  6. #6
    SitePoint Enthusiast joeyramirez's Avatar
    Join Date
    Nov 2011
    Location
    Cabanatuan City, Philippines
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have 10 on the outer loop

  7. #7
    SitePoint Enthusiast joeyramirez's Avatar
    Join Date
    Nov 2011
    Location
    Cabanatuan City, Philippines
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the user can add data on the combo box


Bookmarks

Posting Permissions

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