|
|
|
ASP Search จาก listmenu มันไม่ยอมขึ้นซักทีอ่าคับ........... |
|
|
|
|
|
|
|
Code (ASP)
<% Option Explicit %>
<html>
<head>
<title>My test</title>
</head>
<body>
<form name="frmSearch" method="post" action="search.asp">
<tr><td><div align="center">
<th>List Menu 2
<select name="choose" >
<option value="a">IP</option>
<option value="b">Cillie Code</option>
</select>
</th>
<th>Keyword
<input name="txtKeyword" type="text" id="txtKeyword" value="<%=Request.QueryString("txtKeyword")%> ">
<input type="submit" value="Search"></th>
</tr>
</form>
<%
Dim Conn,strSQL,objRec
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("mydatabase.mdb"),"" , ""
strSQL = "SELECT a.IP,b.Cill,a.Model,a.Version,a.SwImage,a.Port,a.Status,a.Description FROM MyTable as a INNER JOIN Table1 as b on a.IP = b.IP "
'*** Search By IP or Cill ***'
if trim(Request.QueryString("txtKeyword")) <> "" and Request.Form("choose") ="a"Then
strSQL = "SELECT a.IP,b.Cill,a.Model,a.Version,a.SwImage,a.Port,a.Status,a.Description FROM MyTable as a INNER JOIN Table1 as b on a.IP = b.IP "
strSQL = strSQL & "WHERE (a.IP LIKE '%"& trim(Request.QueryString("txtKeyword")) &"%') "
'strSQL = strSQL & "or b.Cill LIKE '%"& Request.QueryString("txtKeyword") &"%' ) "
'strSQL = strSQL & "ORDER BY a.IP,len(a.port),a.port asc"
End IF
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.Open strSQL, Conn, 1,3
%>
<table width="1300" border="1">
<tr>
<th width="100"> <div align="center">IP </div></th>
<th width="98"> <div align="center">Cill </div></th>
<th width="180"> <div align="center">Model </div></th>
<th width="200"> <div align="center">Version </div></th>
<th width="300"> <div align="center">SwImage </div></th>
<th width="100"> <div align="center">Port </div></th>
<th width="250"> <div align="center">Status </div></th>
<th width="500"> <div align="center">Description </div></th>
</tr>
<%
While Not objRec.EOF
%>
<tr>
<td><div align="center"><%=objRec.Fields("IP").Value%></div></td>
<td><%=objRec.Fields("Cill").Value%></td>
<td><%=objRec.Fields("Model").Value%></td>
<td><%=objRec.Fields("Version").Value%></div></td>
<td><%=objRec.Fields("SwImage").Value%></td>
<td><%=objRec.Fields("Port").Value%></td>
<td><%=objRec.Fields("Status").Value%></td>
<td><%=objRec.Fields("Description").Value%></td>
</tr>
<%
objRec.MoveNext
Wend
%>
</table>
<%
objRec.Close()
Conn.Close()
Set objRec = Nothing
Set Conn = Nothing
%>
</body>
</html>
Tag : ASP
|
ประวัติการแก้ไข 2013-05-03 11:44:53 2013-05-03 14:07:25
|
|
|
|
|
Date :
2013-05-03 11:43:54 |
By :
solskjaer16 |
View :
1237 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คุณก็ลอง Response.Write ค่ามันออกมาน่ะครับ
ใช้การ Write ดูค่าแค่ล่ะส่วนครับ
|
|
|
|
|
Date :
2013-05-03 13:19:12 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|