19
2020
03

向 HTML 表格添加颜色


ASP源代码:


<html>

<body>


<%

set conn=Server.CreateObject("ADODB.Connection")

conn.Provider="Microsoft.Jet.OLEDB.4.0"

conn.Open(Server.Mappath("/db/northwind.mdb"))

set rs = Server.CreateObject("ADODB.recordset")

sql="SELECT Companyname, Contactname FROM Customers"

rs.Open sql, conn

%>


<table border="1" width="100%" bgcolor="#fff5ee">

<tr>

<%for each x in rs.Fields

    response.write("<th align='left' bgcolor='#b0c4de'>" & x.name & "</th>")

next%>

</tr>

<%do until rs.EOF%>

    <tr>

    <%for each x in rs.Fields%>

       <td><%Response.Write(x.value)%></td>

    <%next

    rs.MoveNext%>

    </tr>

<%loop

rs.close

conn.close

%>

</table>


</body>

</html>


运行结果:


Screenshot_20200319_134155.jpg

« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。