台灣最大程式設計社群網站
線上人數
1138
 
會員總數:246203
討論主題:189774
歡迎您免費加入會員
討論區列表 >> ASP >> 如何做出分頁及排序
[]  
[我要回覆]
1
回應主題 加入我的關注話題 檢舉此篇討論 將提問者加入個人黑名單
如何做出分頁及排序
價值 : 100 QP  點閱數:1076 回應數:2
樓主

大哥
門外漢
0 28
424 12
發送站內信


想請問一下要如何修改成分頁的方式且可以做時間排序


<!--#include file="db.ini"-->
<html>

<head>
<link rel="StyleSheet" href="mycss76.css" type="text/css">
<title>View</title>
<style type="text/css">
.style1
{
width: 46px;
}
.style2
{
width: 48px;
}
.style4
{
width: 55px;
}
.style5
{
width: 77px;
}
</style>
</head>

<body>
<%
if request("additem1") <> "" and request("additem2") <> "" and request("additem3") <> ""and request("additem4") <> ""and request("additem5") <> ""and request("additem6") <> ""and request("additem7") <> ""and request("additem8") <> ""and request("additem9") <> ""and request("additem10") <> ""and request("additem11") <> ""and request("additem12") <> ""and request("additem13") <> ""and request("additem14") <> ""and request("additem15") <> ""and request("additem16") <> ""then
SQL = "insert into item(""Item1"",""Item2"",""Item3"",""Item4"",""Item5"",""Item6"",""Item7"",""Item8"",""Item9"",""Item10"",""Item11"",""Item12"",""Item13"",""Item14"",""Item15"",""Item16"") values('" & request("additem1") & "','" & request("additem2") & "','" & request("additem3") & "','" & request("additem4") & "','" & request("additem5") & "','" & request("additem6") & "','" & request("additem7") & "','" & request("additem8") & "','" & request("additem9") & "','" & request("additem10") & "','" & request("additem11") & "','" & request("additem12") & "','" & request("additem13") & "','" & request("additem14") & "','" & request("additem15") & "','" & request("additem16") & "');"
db.Execute(SQL)
response.write "Add ok!"
end if
%>

<form action="view.asp" method=post style="width: 244px">
<table>
<tr><td>資產編號 </td><td><input type=text size=20 name=item1 value =<%=request("item1")%>></td></tr>
<tr><td>資產序號 </td><td><input type=text size=20 name=item2 value =<%=request("item2")%>></td></tr>
<tr><td>MIS編號 </td><td><input type=text size=20 name=item3 value =<%=request("item3")%>></td></tr>
<tr><td>使用者工號 </td><td><input type=text size=20 name=item4 value =<%=request("item4")%>></td></tr>
<tr><td>使用者姓名 </td><td><input type=text size=20 name=item5 value =<%=request("item5")%>></td></tr>
<tr><td>電腦OS類別</td><td><select name="item6" >
<option value="">請選擇</option>
<option value="無資料"></option>
<option value="Mac">Mac</option>
<option value="Microsoft">Microsoft</option>
<option value="Ubuntu">Ubuntu</option>
</select> </td></tr>










</table>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type=submit value="Search查詢" style="width: 74px"> </form>
<form action="add.asp" method=post
style="height: 1px; width: 83px; margin-top: 19px; margin-bottom: 1px">
<input type=submit value=新增資料></form>

<br />
<br />

<caption style="width: 113px">

<table border="3">



<TABLE>

<tr>
<th class="style1"></th>
<td align="center" height="24" width="67" style="border:1px solid #C0C0C0; padding-left: 4px; padding-right: 4px; text-align:center" bordercolor="#C0C0C0" bgcolor="#CCCC99">
<font size="2">資產編號</font></td>
<td align="center" height="24"
style="border:1px solid #C0C0C0; padding-left: 4px; padding-right: 4px"
bordercolor="#C0C0C0" bgcolor="#CCCC99" class="style4">
<font size="2">資產序號</font></td>
<td align="center" height="24"
style="border:1px solid #C0C0C0; padding-left: 4px; padding-right: 4px; text-align:center"
bordercolor="#C0C0C0" bgcolor="#CCCC99" class="style2">
<font size="2">MIS編號</font></td>
<td align="center" height="24"
style="border:1px solid #C0C0C0; padding-left: 4px; padding-right: 4px; text-align:center"
bordercolor="#C0C0C0" bgcolor="#CCCC99" class="style5">
<font size="2">使用者工號</font></td>
<td align="center" width="80" height="24" style="border:1px solid #C0C0C0; padding-left: 4px; padding-right: 4px; text-align:center" bordercolor="#C0C0C0" bgcolor="#CCCC99">
<font size="2">使用者姓名</font></td>
<td align="center" width="68" height="24" style="border:1px solid #C0C0C0; padding-left: 4px; padding-right: 4px; text-align:center" bordercolor="#C0C0C0" bgcolor="#CCCC99">
<font size="2">電腦OS類別</font></td>
</tr>
<%
SQL="SELECT TOP 20 * FROM Item "




if request("item1") <> "" then
SQLWHERE = " Item1 ='" & request("item1") & "'"
end if

if request("item2") <> "" then
if SQLWHERE <> "" then
SQLWHERE = SQLWHERE + " and "
end if
SQLWHERE = SQLWHERE + " Item2 ='" & request("item2") & "'"
end if

if request("item3") <> "" then
if SQLWHERE <> "" then
SQLWHERE = SQLWHERE + " and "
end if
SQLWHERE = SQLWHERE + " Item3 ='" & request("item3") & "'"
end if

if request("item4") <> "" then
if SQLWHERE <> "" then
SQLWHERE = SQLWHERE + " and "
end if
SQLWHERE = SQLWHERE + " Item4 ='" & request("item4") & "'"
end if

if request("item5") <> "" then
if SQLWHERE <> "" then
SQLWHERE = SQLWHERE + " and "
end if
SQLWHERE = SQLWHERE + " Item5 ='" & request("item5") & "'"
end if

if request("item6") <> "" then
if SQLWHERE <> "" then
SQLWHERE = SQLWHERE + " and "
end if
SQLWHERE = SQLWHERE + " Item6 ='" & request("item6") & "'"
end if


if SQLWHERE <> "" then
SQL = SQL + " where " + SQLWHERE
end if
Set rs=db.Execute(SQL)
if rs.eof = false then
rs.movefirst
while not rs.eof
response.write "<tr>"

%>
<TR onMouseOver="this.style.backgroundColor='#F0F0F0'" onMouseOut="this.style.backgroundColor='#FFFFFF'" bgcolor="#FFFFFF">

<TD><a href ="info.asp?ID=<%=rs("Index")%>">連結</a></TD>
<td><%=rs("Item1")%></td>
<td class="style4"><%=rs("Item2")%></td>
<td><%=rs("Item3")%></td>
<td class="style5"><%=rs("Item4")%></td>
<td><%=rs("Item5")%></td>
<td><%=rs("Item6")%></td>
</tr>



<%
response.write "</tr>"
rs.movenext
wend
end if
%>


</TABLE>
</body>

<%rs.close
db.close%>


</html>










搜尋相關Tags的文章: [ ASP ] , [ 分頁 ] ,
本篇文章發表於2015-08-06 15:33
1樓
回應

迷路
捐贈 VP 給 迷路 檢舉此回應
發問時,程式碼請使用Code標籤

這兩個功能主要依靠的是SQL而非ASP
分頁功能請Google「SQL LIMIT」
排序功能請Google「SQL ORDER BY」
本篇文章回覆於2015-08-06 15:56
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
2樓
回應

香帥
檢舉此回應
以下程式碼給您參考(asp的書已經不多,這是早期王國榮作者的書上範例(Asp網頁製作教本),我將他改一下,符合您的排序要求)
測試網址在http://ap.a168a.com/blueshop/aspshowpage/blue02.asp
程式碼重點摘要如下:
blue02.asp檔案程式碼

onepage.fun檔案程式碼

db.fun 檔案程式碼

範例資料庫下載http://ap.a168a.com/blueshop/aspshowpage/sample.zip
本篇文章回覆於2015-08-06 20:34
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
   
1

回覆
如要回應,請先登入.