请问这句话,用response.write("")怎么写

zjj010 2009-08-21 01:18:09
我想得到这句话

src='display2.asp?user_id= <%=rs_new("user_id")%>'

用response.write("")怎么写,
能正确得到 src='display2.asp?user_id= <%=rs_new("user_id")%>'
...全文
192 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
ilxl520 2009-08-21
  • 打赏
  • 举报
回复
是你photo值的问题啊
zjj010 2009-08-21
  • 打赏
  • 举报
回复
谢谢"三楼的狼"您指点的非常准确....
也非常感谢其余朋友的斧正...
gxq323 2009-08-21
  • 打赏
  • 举报
回复
很乱,数据库字段有photo,定义的变量也有photo,这儿可以看出(photo=request("photo")),不知道你想用哪个,变量photo的话你的值应该是有或者是没有,从这儿看出的(if c_photo="ON" then
if photo="有" then sql=sql & " and photo>0" else sql=sql & " and photo=0"
hrefdate=hrefdate & "&c_photo=" & "ON" & "&photo=" & photo
end if )
如果想用数据库里的photo的话,读取就行了
所以说很乱
三楼の郎 2009-08-21
  • 打赏
  • 举报
回复
而且Open了那么多Connection,没看到任何Close Connection的,用不了几下你的系统就得歇菜!
chinank 2009-08-21
  • 打赏
  • 举报
回复
这个正解,上面的多个引号:

<% if photo=0 then response.write("src='image/012.jpg'") else response.write(" src='display2.asp?user_id="& rs_new("user_id")& "'") end if %>
三楼の郎 2009-08-21
  • 打赏
  • 举报
回复
代码写得够烂的,基本上属于天书!


…………
if rs_new.fields("photo")<>0 then
%>
<img border="1" src="display2.asp?user_id= <%=rs_new("user_id")%> " width="90" height="120">
<%
else '使用缺省图片
%>
<img border="1" src="image/012.jpg" width="90" height="120">
<%
end if
…………
chinank 2009-08-21
  • 打赏
  • 举报
回复
解:

<% if photo=0 then response.write("src='image/012.jpg'") else response.write(" src="'display2.asp?user_id="& rs_new("user_id")& "'") end if %>
gxq323 2009-08-21
  • 打赏
  • 举报
回复
photo=request("photo")'这的photo是有或者是没有吗?
if c_photo="ON" then
if photo="有" then sql=sql & " and photo>0" else sql=sql & " and photo=0"
hrefdate=hrefdate & "&c_photo=" & "ON" & "&photo=" & photo
end if
这2段搞的最后photo是多少,我也弄不清楚,你最好打印看看
zjj010 2009-08-21
  • 打赏
  • 举报
回复
photo类型是int,默认值是(0)

整页全部代码:
<%Option Explicit%>
<!--#include file="conn.asp"-->

<%
dim connpic
dim rs_user,rs_today,rs_lar,rs_new,rs_board,rs_boy,rs_girl,rs
dim sql,records,today_records,rs_pic
dim i,j,k

if isempty(session("user_id")) then session("user_id")=1


Set rs_boy = Server.CreateObject("ADODB.Recordset")
sql="select * from larchives where photo>0 and sex like '" & "男" & "' order by renqi desc"
rs_boy.open sql,conn,1,1

Set rs_girl = Server.CreateObject("ADODB.Recordset")
sql="select * from larchives where photo>0 and sex like '" & "女" & "' order by renqi desc"
rs_girl.open sql,conn,1,1


Set rs_new = Server.CreateObject("ADODB.Recordset")
rs_new.open "select * from larchives order by lar_id desc",conn,1,1

%>


<%

dim c_age,c_name,c_sex,c_netname,c_home,c_education,c_job,c_netcall,c_tel,c_book,c_music,c_sport,c_interest,c_character,c_photo
dim age1,age2,name,sex,netname,home,education,job,netcall,tel,sport,book,music,interest,character,photo
dim hrefdate, str,pages,currentpage,p,linenumber,line


c_age =request("c_age")
c_name =request("c_name")
c_sex =request("c_sex")
c_netname =request("c_netname")
c_home =request("c_home")
c_education =request("c_education")
c_job =request("c_job")
c_netcall =request("c_netcall")
c_tel =request("c_tel")
c_sport =request("c_sport")
c_book =request("c_book")
c_music =request("c_music")
c_sport =request("c_sport")
c_interest =request("c_interest")
c_character =request("c_character")
c_photo =request("c_photo")

age1 =request("age1")
age2 =request("age2")
name =request("name")
sex =request("sex")
netname =request("netname")
home =request("home")
education =request("education")
job =request("job")
netcall =request("netcall")
tel =request("tel")
sport =request("sport")
book =request("book")
music =request("music")
sport =request("sport")
interest =request("interest")
character =request("character")
photo =request("photo")

Set rs_lar = Server.CreateObject("ADODB.Recordset")

hrefdate=""
sql="select * from larchives where lar_id like '%'"
if c_age="ON" then
sql=sql & " and age>" & clng(age1) & " and age<" & clng(age2)
hrefdate=hrefdate & "&c_age=" & "ON" & "&age1=" & age1 & "age2=" & age2
end if
if c_name="ON" then
sql=sql & " and name like '" & name & "'"
hrefdate=hrefdate & "&c_age=" & "ON" & "&age1=" & age1 & "age2=" & age2
end if
if c_netname="ON" then
sql=sql & " and netname like '" & netname & "'"
hrefdate=hrefdate & "&c_netname=" & "ON" & "&netname=" & netname
end if
if c_sex="ON" then
sql=sql & " and sex like '" & sex & "'"
hrefdate=hrefdate & "&c_sex=" & "ON" & "&sex=" & sex
end if
if c_home="ON" then
sql=sql & " and home like '" & home & "'"
hrefdate=hrefdate & "&c_home=" & "ON" & "&home=" & home
end if

if c_job="ON" then
sql=sql & " and job like '" & job & "'"
hrefdate=hrefdate & "&c_job=" & "ON" & "&job=" & job
end if


if c_education="ON" then
sql=sql & " and education like '" & education & "'"
hrefdate=hrefdate & "&c_education=" & "ON" & "&education=" & education
end if

if c_netcall="ON" then
sql=sql & " and netcall like '%" & netcall & "%'"
hrefdate=hrefdate & "&c_netcall=" & "ON" & "&netcall=" & netcall
end if
if c_tel="ON" then
sql=sql & " and tel like '" & tel & "'"
hrefdate=hrefdate & "&c_tel=" & "ON" & "&tel=" & tel
end if
if c_sport="ON" then
sql=sql & " and sport like '%" & sport & "%'"
hrefdate=hrefdate & "&c_sport=" & "ON" & "&sport=" & sport
end if
if c_book="ON" then
sql=sql & " and book like '%" & book & "%'"
hrefdate=hrefdate & "&c_book=" & "ON" & "&book=" & book
end if
if c_music="ON" then
sql=sql & " and music like '%" & music & "%'"
hrefdate=hrefdate & "&c_music=" & "ON" & "&music=" & music
end if
if c_interest="ON" then
sql=sql & " and interest like '%" & interest & "%'"
hrefdate=hrefdate & "&c_interest=" & "ON" & "&interest=" & interest
end if
if c_character="ON" then
sql=sql & " and character like '%" & character & "%'"
hrefdate=hrefdate & "&c_character=" & "ON" & "&character=" & character
end if

if c_photo="ON" then
if photo="有" then sql=sql & " and photo>0" else sql=sql & " and photo=0"
hrefdate=hrefdate & "&c_photo=" & "ON" & "&photo=" & photo
end if
rs_lar.open sql,conn,1,1
if rs_lar.eof and rs_lar.bof then str="此交友系统还没有一个网友!"
'分页设置
if str="" then
rs_lar.PageSize=25
pages=rs_lar.pagecount
records=rs_lar.recordcount
currentpage=request("currentpage")
if currentpage="" or currentpage<1 then currentpage=1
currentpage=cint(currentpage)
if currentpage>pages then currentpage=pages
rs_lar.absolutepage=currentpage
else
currentpage=1
records=0
pages=1
end if
%>

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Namo WebEditor v4.0(Trial)">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>无</title>



</head>

<body leftmargin="5" topmargin="0">
<table width="772" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>
<td width="185" height="200" valign="top"></p></td>
<td width="428" valign="top">

<!--------------------------------------------------------------------->
<table width="419" height="163" border="0" cellpadding="0" cellspacing="0" bordercolor="#316AC5">
<tr>
<td width="228" valign="top"><%Set connpic = Server.CreateObject("ADODB.Connection")
DBPath = Server.MapPath("data/picture.asp")
connpic.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath

if rs_girl.eof and rs_girl.bof then%>
<table border="0" width="213" cellspacing="0" cellpadding="0">
<tr>
<td width="100" align="right" rowspan="6"> </td>
<td width="15" align="center" rowspan="6"> </td>
<td></td>
</tr>
<tr>
<td rowspan="5"> </td>
</tr>
<tr> </tr>
<tr> </tr>
<tr> </tr>
<tr> </tr>
</table>
<%else
Set rs_pic = Server.CreateObject("ADODB.Recordset")
sql="select * from pic where user_id=" & rs_girl("user_id")
rs_pic.open sql,connpic,1,1

%><%end if%> </td>
<td width="202"><%if rs_boy.eof and rs_boy.eof then%>
<table border="0" width="206" cellspacing="0" cellpadding="0">
<tr>
<td width="100" align="center" rowspan="4"> </td>
<td width="15" align="center" rowspan="4"> </td>
<td width="60"></td>
</tr>
<tr>
<td width="60"></td>
</tr>
<tr>
<td width="60" bgcolor="white"></td>
</tr>
<tr>
<td width="60"></td>
</tr>
</table>
<%else
Set rs_pic = Server.CreateObject("ADODB.Recordset")
sql="select * from pic where user_id=" & rs_boy("user_id")
rs_pic.open sql,connpic,1,1
%>
<%rs_pic.close:set rs_pic=nothing:set connpic=nothing
rs_boy.close:set rs_boy=nothing
end if%>
</td>
</tr>
</table>
</td>
<td width="159" valign="top"> </td>
</tr>
</table>

<table width="772" border="1" align="center">
<tr>
<td width="17" bgcolor="#FF7D01"><img src="image/img/q2.gif" alt="q" width="17" height="31"></td>
<td width="140" align="center" bgcolor="#FF7D01"><font color="#000000">会员照片</font></td>
<td width="368" bgcolor="#FF7D01"><img src="image/img/q1.gif" alt="2" width="17" height="31"></td>
<td bgcolor="#FF7D01"> </td>
</tr>
<tr>
<td height="120" colspan="3" align="left" nowrap><p>
<%i=1%>
<%do while not(rs_new.eof) and i<11%>


<%

Set connpic = Server.CreateObject("ADODB.Connection")
DBPath = Server.MapPath("data/picture.asp")
connpic.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
Set rs_pic = Server.CreateObject("ADODB.Recordset")
sql="select * from pic "
rs_pic.open sql,connpic,1,1

%>







<img border="1" src="display2.asp?user_id=<%=rs_new("user_id")%> " width="90" height="120">



<%i=i+1%>
<%rs_new.movenext%>
<%loop%>
<%rs_new.close%>





 </p> </td>
<td width="219"> </td>
</tr>
</table>
<p>



<!------------------------------------------------------------------------------------------------------------------------->
</p>
</body>

</html>
gxq323 2009-08-21
  • 打赏
  • 举报
回复
还在问啊,是你photo的问题,photo的值是怎么赋的,把代码贴出来看看,其他那些都没用
zjj010 2009-08-21
  • 打赏
  • 举报
回复
可以试着,把<%分开,把这一句分几部分写,但不知道怎么写
qqweird0001 2009-08-21
  • 打赏
  • 举报
回复

正解:

sen = "src='display2.asp?user_id=" & rs_new("user_id") &"'"
Response.Write(sen)

其他的参考一楼
zjj010 2009-08-21
  • 打赏
  • 举报
回复
我是想这样
<% if photo=0 then response.write("src='image/012.jpg'") else response.write(" src="display2.asp?user_id=<%=rs_new("user_id")%> " ") end if %>

输出后的结果就是 如果photo=0
结果是

意思是: 若photo=0 则

<img border="1" src='image/012.jpg'" width="90" height="120">

若photo>0 则

<img border="1" src='display2.asp?user_id=<%=rs_new("user_id")%> width="90" height="120">

我用 if 语句,怎么写,都不能得到正确结果,也问过很多人了,太郁闷了..
loveinet_168 2009-08-21
  • 打赏
  • 举报
回复
response.write("<a href=display2.asp?user_id="&rs_new("user_id")&"</a>")
三楼の郎 2009-08-21
  • 打赏
  • 举报
回复
response.write("src='display2.asp?user_id=" & rs_new("user_id") & "'")
leekeeny 2009-08-21
  • 打赏
  • 举报
回复
response.write是不能重定向的,response.redirect进行重定向。
如果你要以Href的链接传递参数可以这样,<a href="display2.asp?user_id= <%=rs_new("user_id")%>">链接</a>

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧