Control the rows and columns of the table to display the data

Source: Internet
Author: User
Control | data | display

Many 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.

Dimwwwstr,wwwarr
Wwwstr= "51windows.net|blueidea.com|google.com|yahoo.com|msn.com.cn|csdn.net|ipark.cn|1kg.cn"
Wwwarr=split (wwwstr, "|")

Functionurltest1 (str)
Response.Write ("<ahref=" "".) &str& "" "target=" "_blank" ">" &str& "</a>")
Endfunction

<tableborder= "1" width= "cellpadding=" "2" >
<%calltablebody (wwwarr,3, "Urltest1")%>
</table>

Function code:

Functiontablebody (ARR,COLS,FUNCTIONSTR)
' Arr array
' Cols is the number of columns
' Functionstr function for output content, not NULL

 dimallnum,i,j
 allnum=ubound (arr)
 fori=0to (allnum/cols)
   Response.Write (vbtab& "<tr>" &vbnewline)
  forj=0to (cols-1)
   ij= ( I*COLS+J)
   response.write (vbtab&vbtab& "<tdwidth=" "" &formatnumber (100/cols,0 ) & "%" ">")
   ifij<=allnumthen
    iflen (FUNCTIONSTR) > 0then
     execute (arr (ij))
     else
     response.write (arr (ij))
    endif
    else
    response.write (" ")
   endif
    response.write ("</td>" &vbnewline)
  next
  response.write (VbTab& "</tr>" &vbnewline)
 next
Endfunction

Functiontest1 (str)
Response.Write ("<divalign=" "Center" ">" &str& "</div>")
Endfunction



Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.