|
|
|
ช่วยดูโค้ดให้หน่อยค่ะต้องการให้มันค้นหาข้อมูลได้ 2 Keyword คือค้นหาจาก รหัสหรือชื่อบริษัท หรือทั้งสองยังพร้อมกันก็ได้ |
|
|
|
|
|
|
|
ช่วยดูโค้ดให้หน่อยค่ะต้องการให้มันค้นหาข้อมูลได้ 2 Keyword คือค้นหาจาก รหัสหรือชื่อบริษัท หรือทั้งสองอย่างพร้อมกันก็ได้
Code (ASP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.style7 {
color: #7200A8;
font-size: 14px;
}
body,td,th {
font-family: Microsoft Sans Serif;
font-size: 14px;
color: #660000;
}
.style10 {font-family: Microsoft Sans Serif; font-weight: bold;}
.style12 {font-family: Microsoft Sans Serif}
a:link {
color: #0000FF;
}
a:visited {
color: #0000FF;
}
a:hover {
color: #0000FF;
}
a:active {
color: #0000FF;
}
.style13 {font-family:Microsoft Sans Serif; font-size: 14px; font-weight: bold; color: #000000; }
.style15 {font-family:Microsoft Sans Serif; font-weight: bold; color: #000000; }
.style16 {color: #000000}
-->
</style>
<style type="text/css">
body
{
font:12px Verdana, Arial, Helvetica, sans-serif;
margin-left: 0px;
}
.oddtr
{
background-color:#ECECFF;
}
.eventr
{
background-color:#DDDDFF;
}
.trover
{
background-color: #E4CBCB;
}
.style20 {font-size: 9px}
.style20 {font-size: 9px}
.style29 {font-size: 14px}
.style30 {font-weight: bold; font-family: Microsoft Sans Serif;}
.style32 {
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #333333;
}
</style>
<script src="jquery.js"></script>
<script>
$(function()
{
// Developed by Roshan Bhattarai
// Visit http://roshanbh.com.np for this script and more.
// This notice MUST stay intact for legal use
//these two line adds the color to each different row
$("#mytable tr:even").addClass("eventr");;
$("#mytable tr:odd").addClass("oddtr");;
//handle the mouseover , mouseout and click event
$("#mytable tr").mouseover(function() {$(this).addClass("trover");}).mouseout(function() {$(this).removeClass("trover");}).click(function() {$(this).toggleClass("trclick");});
});
</script></head>
<body>
<form id="form1" name="frmSearch" method="get" action="<%=Request.ServerVariables("QUOTATION")%>">
<table width="1079" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="1079" height="20" valign="middle" background="viewcustomer/p7.gif"> <span class="style7"> : : <span class="style10"> VIEW ALL QUOTATION </span></span></td>
</tr>
<tr>
<td height="25" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
</table>
<table width="1078" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="84" rowspan="2" valign="top"><!--DWLayoutEmptyCell--> </td>
<td width="88" height="52" valign="middle"><div align="right" class="style13">Quotation : </div></td>
<td width="159" valign="middle"><label for="textfield"></label>
<input type="text" name="txtKeyword" id="txtKeyword" value="<%=Request.QueryString("txtKeyword")%>"/></td>
<td width="747" align="left" valign="middle">
<label for="imageField"></label>
<input type="image" name="imageField" src="viewcustomer/p2.gif" id="imageField" /></td>
</tr>
<tr>
<td height="18" colspan="3" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
</table>
<%
Dim Conn,strSQL,objRec
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "Driver={SQL Server};Server=localhost;Database=mydatabase;Uname=THAISINTO/ADMINISTRATION;PWD=;"
'*** Search By Name or Email ***'
strSQL = "select QUOTATION.*,cust_NAME.*,cust_add.* from QUOTATION,cust_NAME,cust_add where QUOTATION.customer_ID=cust_NAME.customer_ID and QUOTATION.add_ID=cust_add.add_ID and cust_NAME.cust_name LIKE '%"& Request.QueryString("txtKeyword") &"%' or QUOTATION.quote_no LIKE '%"& Request.QueryString("txtKeyword") &"%' "
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.Open strSQL, Conn, 1,3
If objRec.EOF Then
Response.write("<font color=red>Not found data!</font>")
Else
Dim PageLen,PageNo,TotalRecord,TotalPage,No,intID
PageLen = 5
PageNo = Request.QueryString("Page")
if PageNo = "" Then PageNo = 1
TotalRecord = objRec.RecordCount
objRec.PageSize = PageLen
TotalPage = objRec.PageCount
objRec.AbsolutePage = PageNo
End IF
%>
<table width="1072" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="7" height="53"></td>
<td colspan="2" valign="top"><table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#666666" id="mytable">
<!--DWLayoutTable-->
<tr>
<td width="70" height="25" valign="middle" background="viewcustomer/p3.gif"><div align="center" class="style13">View</div></td>
<td width="112" valign="middle" background="viewcustomer/p3.gif"><div align="center" class="style13">Quotation</div></td>
<td width="359" valign="middle" background="viewcustomer/p3.gif"><div align="center" class="style13">Customer</div></td>
<td width="172" valign="middle" background="viewcustomer/p3.gif"><div align="center" class="style13">Model</div></td>
<td width="347" valign="middle" background="viewcustomer/p3.gif"><div align="center" class="style13"> Description</div></td>
</tr>
<%
No=1
While Not objRec.EOF and No <= PageLen
%>
<tr>
<td height="25" valign="middle"><div align="center"><a href="viewquotation1.asp?CusID=<%=objRec.Fields("quote_no").Value%>" target="_top"><img src="quotation/p1.gif" alt="Edit" width="56" height="24" border="0" /></a></div></td>
<td valign="middle"> <%=objRec.Fields("quote_no").Value%></td>
<td valign="middle"> <%=objRec.Fields("cust_name").Value%></td>
<td valign="middle"> <%=objRec.Fields("model").Value%></td>
<td valign="middle"> <%=objRec.Fields("quote_title").Value%></td>
</tr>
<%
No = No + 1
objRec.MoveNext
Wend
%>
</table></td>
</tr>
<tr>
<td height="48"></td>
<td width="693" valign="top"> <span class="style15">Total</span><span class="style16"> :</span> <%=TotalRecord%> <span class="style15">Page</span><br />
<span class="style15">Go to <span class="style12">:</span></span>
<% For intID = 1 To TotalPage%>
<% if intID = Cint(PageNo) Then%>
<%=intID%>
<%Else%>
<a href="<%Request.ServerVariables("QUOTATION")%>?Page=<%=intID%>"><%=intID%></a>
<%End IF%>
<%Next%>
<%
objRec.Close()
Conn.Close()
Set objRec = Nothing
Set Conn = Nothing
%></td>
<td width="372"> </td>
</tr>
<tr>
<td height="701"></td>
<td> </td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
Tag : ASP, Ms SQL Server 2005
|
|
|
|
|
|
Date :
2011-06-22 14:21:01 |
By :
gusjang |
View :
1417 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใช้ OR ก็ถูกแล้วครับ
|
|
|
|
|
Date :
2011-06-22 15:56:31 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|