#2
yiyanxiyin2023-07-10 18:39
|
如何输入一个关键字,查询数据库中的数据并显示出来?
有没有现成的asp代码给发一段?输入框、按钮都做好了,不知道按钮的执行命令放在哪儿?
VFP转过来学习的老白(50岁中年小白)
代码如下:如果有大神给改一下就更好了
程序代码:
<!--#include file="conn.asp" -->
<%
if request("cxdh")<>"" or request("cxdh.x")<>"" then
'查询数据
strSQL = "select * from yzdh where yzdz like '%"&request("telc")&"%' or lxdh like '%"&request("telc")&"%' "
ExecSQL(strSQL)
'strsql="select * from yzdh where yzdz like '%"&request("telc")&"%' or lxdh like '%"&request("telc")&"%'"
end if
if request("BEdit")<>"" or request("BEdit.x")<>"" then
'修改数据
strSQL = "update yzdh set yzdz='"&request("yzdz")&"',lxdh = '"&request("lxdh")&"' where id = '"&request("id")&"'"
'response.write strSQL
'response.end
ExecSQL(strSQL)
end if
if request("BDel")<>"" or request("BDel.x")<>"" then
'删除数据
strSQL = "update yzdh set sf = 0 where id = "&request("id")&" "
ExecSQL(strSQL)
end if
if request("BAdd")<>"" or request("BAdd.x")<>"" then
'增加数据
strSQL = "insert into yzdh(yzdz,lxdh) values('"&request("yzdz")&"','"&request("lxdh")&"') "
ExecSQL(strSQL)
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>业主电话管理</title>
<style>
.tbradius
{
border-color: #cfc4a6;
border-width: 1px;
border-style: solid;
border-radius: 0.4em;
background-color:#f2ecdc
}
.tbradius1 {border-color: #cfc4a6;
border-width: 1px;
border-style: solid;
border-radius: 0.4em;
background-color:#f2ecdc
}
</style>
</head>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" bgcolor="#e9e0c9">
<table border="1" width="100%" cellspacing="3" cellpadding="0" style="border-width: 0">
<tr>
<td class="tbradius" style="background-color: #685A37" height="25">
<font color="#FFFFFF">
<span style="font-size: 12px; font-weight: 700">业主电话管理</span> </font></td>
</tr>
</table>
<tr>
<td>
<p align="left">地址: <input type="text" name="telc" size="20" style="border: 1px solid #C0C0C0; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px" value = "30-1-"> <input type="submit" value=" 查询 " name="cxdh">
</td>
</tr>
<table border="0" width="100%" cellspacing="3" cellpadding="0">
<tr>
<td style="border-bottom:1px solid #C0C0C0; border-left-width: 1px; border-right-width: 1px; background-color:#CFC4A6" width="100" height="30" align="center" class="tbradius">
<span style="font-size: 9pt"><b>编号</b></span></td>
<td style="border-bottom:1px solid #C0C0C0; border-left-width: 1px; border-right-width: 1px; background-color:#CFC4A6" width="120" height="30" align="center" class="tbradius">
<b><span style="font-size: 9pt">地址</span></b></td>
<td style="border-bottom:1px solid #C0C0C0; border-left-width: 1px; border-right-width: 1px; background-color:#CFC4A6" width="70" height="30" align="center" class="tbradius">
<b><span style="font-size: 9pt">电话</span></b></td>
<td style="border-bottom:1px solid #C0C0C0; border-left-width: 1px; border-right-width: 1px; background-color:#CFC4A6" width="70" height="30" align="center" class="tbradius">
<b><span style="font-size: 9pt">添加时间</span></b></td>
<td style="border-bottom:1px solid #C0C0C0; border-left-width: 1px; border-right-width: 1px; background-color:#CFC4A6" width="100" height="30" class="tbradius">
<p align="center"><b><span style="font-size: 9pt">操作</span></b></td>
</tr>
<%
set rs_yzdh= Server.CreateObject("ADODB.Recordset")
strsql="select top 100 * from yzdh where sf = 1 order by id desc"
rs_yzdh.open strsql,strconn,1,1
do while (not rs_yzdh.EOF)
%>
<form id="form_<%=rs_yzdh("id")%>">
<tr>
<td style="border-left-width: 1px; border-right-width: 1px" width="100" height="32"><input id="id" name="id" value = "<%=rs_yzdh("id")%>" style="width:100% ; height:100%" readonly class="tbradius"></td>
<td style="border-left-width: 1px; border-right-width: 1px" width="70" height="32"><input id="yzdz" name="yzdz" value="<%=rs_yzdh("yzdz")%>" style="width:100% ; height:100%" class="tbradius"></td>
<td style="border-left-width: 1px; border-right-width: 1px" width="70" height="32"><input id="lxdh" name="lxdh" value="<%=rs_yzdh("lxdh")%>" style="width:100% ; height:100%" class="tbradius"></td>
<td style="border-left-width: 1px; border-right-width: 1px" height="32" width="100"><input id="tjsj" name="tjsj" value="<%=rs_yzdh("tjsj")%>" style="width:100% ; height:100%" class="tbradius" size="1"></td>
<td style="border-left-width: 1px; border-right-width: 1px" width="100" align="center" class="tbradius"><input border="0" src="images/save.png" name="BEdit" width="32" height="32" type="image"><input border="0" src="images/delete.png" name="BDel" width="32" height="32" type="image"></td>
</tr>
<tr>
<td style="border-left-width: 1px; border-right-width: 1px;height:5px" colspan="7" width="100" background="images/line.png"><img border="0" src="images/line.png" width="6" height="5"></td>
</tr>
</form>
<%
rs_yzdh.movenext
loop
rs_yzdh.close:set rs_yzdh= nothing
%>
<form id="form_0">
<tr>
<td style="border-left-width: 1px; border-right-width: 1px" width="100" height="32" class="tbradius"><img border="0" src="images/auto.png" width="32" height="32"></td>
<td style="border-left-width: 1px; border-right-width: 1px" width="70" height="32"><input id="yzdz" name="yzdz" value="" style="width:100% ; height:100%" class="tbradius"></td>
<td style="border-left-width: 1px; border-right-width: 1px" width="70" height="32"><input id="lxdh" name="lxdh" value="" style="width:100% ; height:100%" class="tbradius1"></td>
<td style="border-left-width: 1px; border-right-width: 1px" height="32" width="100"><input id="busw" name="bzsw" value="" style="width:100% ; height:100%" class="tbradius" size="1"></td>
<td style="border-left-width: 1px; border-right-width: 1px" width="100" align="center" class="tbradius">
<input border="0" src="images/save.png" name="BAdd" width="32" height="32" type="image"></td>
</tr>
</form>
</table>
</body>
</html>
[此贴子已经被作者于2023-7-10 18:15编辑过]