www.webdeveloper.com
Results 1 to 5 of 5

Thread: loop columns

  1. #1
    Join Date
    Jan 2005
    Posts
    80

    loop columns

    i heard from my fren in order to loop columns, we have to do a mode function. is it true? is there another way we can do so? this is the hyperlink to the kind of table i wan,jus for reference. http://www.ntsmp.com/ntsmp_zl/Englis...ce_general.htm

    ok, wat i have to do is to display for eg products units that are bigger than a certain number a user keys in. so for eg if the product unit is 100 and the user will to select greater than 100, i'll display all the records in that order. so, instead of loop it like that
    1
    1
    1
    1
    1
    1
    1

    i wan to loop it like that 1 1 1 1 1 1 1 1 1 1. possible?

  2. #2
    Join Date
    Jan 2005
    Posts
    80

    any one out there?

    is it poss to loop vertically?

    this is my code, someone help please.
    Code:
    Dim conn,sConnString
    
    Set conn = Server.CreateObject("ADODB.Connection")
       
    sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _ 
    "Data Source=" & Server.MapPath("./search.mdb") 
    
    conn.open(sConnString)
    
    sql =  "Select * from PBT where item = '" &i& "'AND unit = '" &u& "'"
    Set Rs = Server.CreateObject("ADODB.RecordSet")
    Rs.open sql,conn
    If Rs.eof then
    Response.write "No records found,please try again!!!"
    %>
    
    <%Else
    
    	ex = request.form("exp")
    	if ex = "greater or equals to" then
    	
    	sqlC =  "Select Item, Grade, GradeName from SubGrade where Grade > " &g& " AND PBTID = "&rs("PBTID")&""
    	
    	elseif ex = "Equals to" then
    	sqlC =  "Select Item, Grade, GradeName from SubGrade where Grade = " &g& " AND PBTID = "&rs("PBTID")&""
    	
    	else
    	sqlC =  "Select Item, Grade, GradeName from SubGrade where Grade < " &g& " AND PBTID = "&rs("PBTID")&""
    	
    	end if
    	Set RSC = Server.CreateObject("ADODB.RecordSet")
    	RSC.open sqlC,conn
    	response.write sqlC
    %>
    <form name="form1" method="post" action="">
      <table width="518" border="2" cellspacing="4" cellpadding="1">
        <tr> 
          <td width="176" rowspan="2"><div align="center"><strong>Item</strong></div></td>
          <td width="147"><div align="center"><strong>Test Method</strong></div></td>
          <td width="77" rowspan="2"><div align="center"><strong>Unit</strong></div></td>
          <td width="78" rowspan="2"><div align="center"><strong>Test Condition</strong></div></td>
        </tr>
        <tr> 
          <td><div align="center"><strong>ASTM</strong></div></td>
        </tr>
        <% Do while not Rs.eof%>
        <tr> 
          <td><div align="center"><%= i%></div></td>
          <td><div align="center"><%=Rs("Method")%></div></td>
          <td><div align="center"><%= u%></div></td>
          <td><div align="center"><%=Rs("TestCon")%></div></td>
        </tr>
      </table>
      <table width="260" border="0" cellspacing="4" cellpadding="4">
      	<% Do while not RSC.eof%>
        <tr> 
          <td width="244" colspan="3"><div align="center"><strong><%=RSC("GradeName")%></strong></div></td>
        </tr>
        <tr>
          <td colspan="3"><div align="center"><%=RSC("Item")%></div>
       </td>   
        </tr>
    	
        <tr> 
          <td colspan="3"><div align="center"> <%=RSC("Grade")%></div></td>
        </tr>
    <%
    RsC.movenext
    Loop
    %>
    <%
    Rs.movenext
    Loop
    End if
    %>
      </table>

  3. #3
    Join Date
    Jan 2005
    Posts
    80

    any one out there?

    is it poss to loop vertically?

    this is my code, someone help please.
    Code:
    Dim conn,sConnString
    
    Set conn = Server.CreateObject("ADODB.Connection")
       
    sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _ 
    "Data Source=" & Server.MapPath("./search.mdb") 
    
    conn.open(sConnString)
    
    sql =  "Select * from PBT where item = '" &i& "'AND unit = '" &u& "'"
    Set Rs = Server.CreateObject("ADODB.RecordSet")
    Rs.open sql,conn
    If Rs.eof then
    Response.write "No records found,please try again!!!"
    %>
    
    <%Else
    
    	ex = request.form("exp")
    	if ex = "greater or equals to" then
    	
    	sqlC =  "Select Item, Grade, GradeName from SubGrade where Grade > " &g& " AND PBTID = "&rs("PBTID")&""
    	
    	elseif ex = "Equals to" then
    	sqlC =  "Select Item, Grade, GradeName from SubGrade where Grade = " &g& " AND PBTID = "&rs("PBTID")&""
    	
    	else
    	sqlC =  "Select Item, Grade, GradeName from SubGrade where Grade < " &g& " AND PBTID = "&rs("PBTID")&""
    	
    	end if
    	Set RSC = Server.CreateObject("ADODB.RecordSet")
    	RSC.open sqlC,conn
    	response.write sqlC
    %>
    <form name="form1" method="post" action="">
      <table width="518" border="2" cellspacing="4" cellpadding="1">
        <tr> 
          <td width="176" rowspan="2"><div align="center"><strong>Item</strong></div></td>
          <td width="147"><div align="center"><strong>Test Method</strong></div></td>
          <td width="77" rowspan="2"><div align="center"><strong>Unit</strong></div></td>
          <td width="78" rowspan="2"><div align="center"><strong>Test Condition</strong></div></td>
        </tr>
        <tr> 
          <td><div align="center"><strong>ASTM</strong></div></td>
        </tr>
        <% Do while not Rs.eof%>
        <tr> 
          <td><div align="center"><%= i%></div></td>
          <td><div align="center"><%=Rs("Method")%></div></td>
          <td><div align="center"><%= u%></div></td>
          <td><div align="center"><%=Rs("TestCon")%></div></td>
        </tr>
      </table>
      <table width="260" border="0" cellspacing="4" cellpadding="4">
      	<% Do while not RSC.eof%>
        <tr> 
          <td width="244" colspan="3"><div align="center"><strong><%=RSC("GradeName")%></strong></div></td>
        </tr>
        <tr>
          <td colspan="3"><div align="center"><%=RSC("Item")%></div>
       </td>   
        </tr>
    	
        <tr> 
          <td colspan="3"><div align="center"> <%=RSC("Grade")%></div></td>
        </tr>
    <%
    RsC.movenext
    Loop
    %>
    <%
    Rs.movenext
    Loop
    End if
    %>
      </table>

  4. #4
    Join Date
    Jan 2003
    Location
    USA
    Posts
    688
    Well here is a snippet of code I've used to create a string of e-mail addresses. And of course if one did a Response.Write strUserEmails it would print out horizontally:

    ' *** Build strUserEmails - E-mail addresses separated by comma and space.
    ' Set sql.
    strSQL = "SELECT UserEmail "
    strSQL = strSQL & "FROM tblUser "
    strSQL = strSQL & "WHERE (1=1) "
    strSQL = strSQL & " AND (UserEmail Is Not Null) "
    strSQL = strSQL & " AND (UserIsEmailNotif=True) "
    strSQL = strSQL & "ORDER BY UserLName, UserFName "

    ' Open rs.
    Set objRS = Server.CreateObject("ADODB.Recordset")
    objRS.Open strSQL, objConn

    ' If no recs.
    If objRS.EOF Then
    ' Close rs.
    objRS.Close
    Set objRS = Nothing

    Exit Function
    Else
    ' Put recs into array for speed.
    arrayRS = objRS.GetRows

    ' Close rs.
    objRS.Close
    Set objRS = Nothing

    ' Init.
    strUserEmails = ""

    ' Loop thru rows (i.e. recs).
    For I = 0 To UBound(arrayRS, 2)
    ' Set var using each fld's col num.
    UserEmail = arrayRS(0, I)
    strUserEmails = strUserEmails & ", " & UserEmail
    Next

    ' Remove initial comma and space.
    strUserEmails = Right(strUserEmails, Len(strUserEmails) - 2)
    End If
    Last edited by Bullschmidt; 02-09-2005 at 07:58 AM.
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips

  5. #5
    Join Date
    Jan 2003
    Location
    USA
    Posts
    688
    And as a related note you might find these of interest:

    Classic ASP Design Tips - Multiple Records in Each Row
    http://www.bullschmidt.com/devtip-mu...sineachrow.asp

    How do I change a list into a set of table rows and columns?
    http://www.aspfaq.com/show.asp?id=2247
    Code is a little complicated as can handle any number of columns.
    Last edited by Bullschmidt; 01-09-2006 at 09:28 PM.
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles