<% Function chk_regist(requestname,requestpwd,tablename,namefield,pwdfield,reurl) dim cn_name,cn_pwd cn_name=trim(request.form(""&requestname&"")) cn_pwd=trim(request.form(""&requestpwd&"")) if cn_name="" or cn_pwd="" then response.Write("<script language=javascript>alert(""请将帐号密码填写完整,谢谢合作。"");history.go(-1)</script>") end if Set rs = Server.CreateObject ("ADODB.Recordset") sql = "Select * from "&tablename&" where "&namefield&"='"&cn_name&"'" rs.open sql,conn,1,1 if rs.eof then response.Write("<script language=javascript>alert(""没有该会员ID,请确认有没有被申请。"");history.go(-1)</script>") else if rs(""&pwdfield&"")=cn_pwd then session("cn_name")=rs(""&namefield&"") response.Redirect(reurl) else response.Write("<script language=javascript>alert(""提醒,您的帐号和密码是不吻合。注意数字和大小写。"");history.go(-1)</script>") end if end if rs.close Set rs = Nothing End Function %> |
<% call chk_regist("b_name","b_pwd","cn_admin","cn_name","cn_pwd","admin.asp") %> |
<% Function pvouch(tablename,fildname,autoidname,indexid) dim fildvalue Set rs = Server.CreateObject ("ADODB.Recordset") sql = "Select * from "&tablename&" where "&autoidname&"="&indexid rs.Open sql,conn,2,3 fildvalue=rs(""&fildname&"") if fildvalue=0 then fildvalue=1 else fildvalue=0 end if rs(""&fildname&"")=fildvalue rs.update rs.close Set rs = Nothing End Function %> |
<% dowhat=request.QueryString("dowhat") p_id=cint(request.QueryString("p_id")) if dowhat="tj" and p_id<>"" then call pvouch("cn_products","p_vouch","p_id",p_id) end if %> <%if rs("p_vouch")=0 then%> <a href=showpro.asp?dowhat=tj&p_id=<%=rs("p_id")%>>推荐</a> <%else%> <a href=showpro.asp?dowhat=tj&p_id=<%=rs("p_id")%>>取消推荐</a> <%end if%> |
<% function showpros(tablename,topnum,fildname,loopnum,typenum) Set rs = Server.CreateObject ("ADODB.Recordset") sql = "Select top "&topnum&" * from "&tablename rs.Open sql,conn,1,1 if rs.eof and rs.bof then response.Write("暂时无该记录") else response.Write("<table width='100%'>") for i=1 to rs.recordcount if (i mod loopnum=1) then response.write"<tr>" end if select case typenum case "1" response.Write("<td><table width='100%'><tr><td bgcolor=red width='50%'>") response.Write(rs(""&fildname&"")) response.Write("</td><td bgcolor=black>") response.Write("方式1之"&i&"记录")'此处的“方式1”可以替换显示为其余字段的值 response.Write("</td></tr>")'如果字段比较多,继续添加新个表格行来显示 response.Write("</table></td>") case "2" response.Write("<td><table width='100%'><tr><td bgcolor=red>") response.Write(rs(""&fildname&"")) response.Write("</td></tr>") response.Write("<tr><td bgcolor=black>") response.Write("方式2之"&i&"记录") response.Write("</td></tr>") response.Write("</table></td>") end select if (i mod loopnum=0) then response.write"</tr>" end if rs.movenext next response.Write("</table>") end if rs.close Set rs = Nothing end function %> |
<% if request.form("submit")<>"" then topnum=request.form("topnum") loopnum=request.form("loopnum") typenum=request.form("typenum") else topnum=8 loopnum=2 typenum=1 end if %> <%call showpros("cn_products",topnum,"p_name",loopnum,typenum)%> <form action=index.asp method=post> 显示的记录总数:<input name=topnum value=<%=topnum%>> 显示的行循环数:<input name=loopnum value=<%=loopnum%>> 显示的方式类型:<select name=typenum> <option value="1">方式1</option> <option value="2">方式2</option> </select> <input type=submit name=submit value=Sure> </form> |
……