主题:  这一段代码放在那儿好呢?

楚楚

职务:普通成员
等级:1
金币:1.0
发贴:187
#12004/1/11 10:15:11
这一段代码,提取“本栏目有图片的新闻”并显示一张图片。

<%
sqlpic = "SELECT * FROM news WHERE lanmuid=" + cstr(rs("id")) + " AND img <> '' ORDER BY id DESC"
rspic.open sqlpic, conn, 1, 1

if rspic.bof and rspic.eof then
		rspic.close
		
	else
response.write "<a target='_self' href='admin/vew.asp?id=" + cstr(rs1("id")) + "' ><img border=0 src="&rspic("img")&" 

width=150 align=left></a>"
rspic.close
	
end if
%>


但是不知道放在哪儿好,我想放在图片中红框的位置,但我尝试两天了都不成功。请高手指点迷津。谢谢。

图片如下:


现在全页的代码是这样的:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> 
<!--#include file="conn.asp"-->
<link rel="stylesheet" type="text/css" href="admin/Admin_Style.css">
<% dim rs, sql, rs1, sql1,rspic, splpic
dim FIRSTNO, PERPAGE
FIRSTNO = 5	'首页显示新闻个数
PERPAGE = 25	'每页显示记录数

set rs = server.createobject("adodb.recordset")
set rs1 = server.createobject("adodb.recordset")
set rspic = server.createobject("adodb.recordset")
%>

<%
function InsertZero(M)
if len(M)=1 then
InsertZero="0"&M
else
InsertZero=M
end if
end function

function GetDate(D)
GetDate=DatePart("m",D)&"月"&InsertZero(DatePart("d",D))&"日"
end function
%>

<table align="center" width="60%" cellspacing="0" cellpadding="0" border="0" class="border">
<tr>
<td width="*" valign="TOP">
<% 
'新闻类别
sql = "SELECT * FROM fenlei"
rs.open sql, conn, 1, 1
if err.number <> 0 then
	response.write "数据库出错"
else
	if rs.bof and rs.eof then
		rs.close
		response.write "没有类别"
	else
		do while not rs.eof
			response.write "<table width='100%' cellspacing=1 cellpadding=2><tr><td 

background=admin/images2/topBar_bg.gif height=22 >&nbsp;<img src=admin/images2/d.gif>&nbsp;"
			response.write rs("lanmu") + "</td></tr>"
			response.write "<tr><td>"

'本类别新闻标题
sql1 = "SELECT * FROM news WHERE lanmuid=" + cstr(rs("id")) + " ORDER BY id DESC"
rs1.open sql1, conn, 1, 1
if err.number <> 0 then
	response.write "数据库出错"
else
	if rs1.bof and rs1.eof then
		rs1.close
		response.write "没有新闻"
	else
	
		for i = 1 to FIRSTNO
			response.write "<img src=admin/images2/dian.gif><a target='_self' href='admin/vew.asp?id=" + cstr

(rs1("id")) + "'>" + rs1("biaoti") + "<font color=#666666>(" + GetDate(rs1("shijian")) + "</font>)  </a><br>"
			rs1.movenext
			if rs1.eof then exit for
		next
		rs1.close
		
	end if
end if

response.write "999"
response.write "<p align=right>"
response.write "<a target='_self' href='gelei.asp?id=" + cstr(rs("id")) + "'>&nbsp;<img src=admin/images2/more.gif 

border=0>&nbsp;更多新闻...</a></p>"			
			response.write "</td></tr></table>"

			rs.movenext
		loop
		rs.close
	end if
end if
 %>
</table>
<%
set rs1 = nothing
set rs = nothing
set rspic = nothing
 %>