ASP Practical Tips: Control the rows of tables to display data
Source: Internet
Author: User
Skills | control | data | Show a lot of times, when we display the contents of a database, we use a few rows or columns to display the data, such as 10 data, to be displayed in 2 or 3 columns per row.
Here is a simple listing code that uses an array to display a few rows of columns in a table, in the hope of helping you.
<%
function Tablebody (ARR,COLS,FUNCTIONSTR)
' Arr array
' Cols is the number of columns
' Functionstr function for output content, not NULL
Dim allnum,i,j
Allnum = UBound (arr)
For i = 0 to (allnum/cols)
Response.Write (VbTab & "<tr>" & vbNewLine)
For j = 0 to (cols-1)
IJ = (i*cols+j)
Response.Write (VbTab & VbTab & "<td width=" "" & FormatNumber (100/cols,0) & "%" ">")
If IJ <= Allnum Then
If Len (FUNCTIONSTR) > 0 Then
Execute ("& Functionstr &" (arr (IJ))
Else
Response.Write (arr (IJ))
End If
Else
Response.Write ("")
End If
Response.Write ("</td>" & vbNewLine)
Next
Response.Write (VbTab & "</tr>" & vbNewLine)
Next
End Function
function Test1 (str)
Response.Write ("<div align=" "Center" ">" & str & "</div>")
End Function
' Example 1
Dim kk (9)
For k = 0 to 9
KK (k) = K+1
Next
%>
<table border= "1" width= "cellpadding=" 2 ">
<%call tablebody (kk,1, "")%>
</table>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service