回 帖 发 新 帖 刷新版面

主题:[讨论]这2段代码,怎么样在一个页面里显示  谢谢

第一段代码
<%
strCurrMenu="14754"
ThisPage=request.ServerVariables("URL")
strClassName=GetVariable("classname")
if strClassName="" then
    strClassName="所有产品"
end if

strQuery=""

strClass=GetVariable("class")
if strClass<>"" then
    SourCode=conn.execute("Select c_code From web_product_class Where mn_id=" & strCurrMenu & " and id="&strClass)(0)
    strQuery=strQuery & " And c_code Like '" & SourCode &"%'"
end if

strKey=GetVariable("key")
if strKey<>""  then
    strQuery=strQuery & " And (p_name Like '%" & strKey & "%' Or p_detail Like '%" & strKey & "%') "
    strClassName="搜索:" & strKey
end if

strPrice1=GetVariable("price1")
if strPrice1<>"" then
    strQuery=strQuery & " And p_price>=" & strPrice1 
    strClassName=strClassName & "  最低价格" & strPrice1
end if

strPrice2=GetVariable("price2")
if strPrice2<>"" then
    strQuery=strQuery & " And p_price<=" & strPrice2
    strClassName=strClassName & "  最高价格" & strPrice1
end if

%>
<%
'读取产品展示的属性,以确定显示那个字段
showClass=GetKey("showClass",WebUserID,"product_" & strCurrMenu )
showPrice=GetKey("showPrice",WebUserID,"product_" & strCurrMenu )
showSize=GetKey("showSize",WebUserID,"product_" & strCurrMenu )
showSymbol=GetKey("showSymbol",WebUserID,"product_" & strCurrMenu )
showFace=GetKey("showFace",WebUserID,"product_" & strCurrMenu )
showShop=GetKey("showShop",WebUserID,"product_" & strCurrMenu )
showDetail=GetKey("showDetail",WebUserID,"product_" & strCurrMenu )
%>

                  <!--Product Begin-->
                  
<%
                    strSQL="Select * From v_web_product Where mn_id=" & strCurrMenu & strQuery & " Order by p_code,ID Desc"
                    Set rs=Server.CreateObject("ADODB.RecordSet")
                    rs.open strSQL,conn,1,1
                    '分页显示初始化
                    page=GetVariable("page")
                    if page="" then
                        page=1
                    else
                        page=Cint(page)
                    end if
                    
                    Section=GetVariable("section")
                    if Section="" then
                        Section=1
                    else
                        Section=Cint(Section)
                    end if
                    '变量赋值
                    intPageSize=3        '每页显示记录数
                    intSectionSize=5        '多少页为一段,像GOOGLE一样
                    PrevSectionText="<FONT face=webdings>7</FONT>"        '上一段的链接文字
                    NextSectionText="<FONT face=webdings>8</FONT>"        '下一段的链接文字
                    PrevPageText="<FONT face=webdings>3</FONT>"            '上页的链接文字    
                    NextPageText="<FONT face=webdings>4</FONT>"            '下页的链接文字
                    
                    strPageUrl="?class=" & GetVariable("class") & "&key=" & GetVariable("key") & "&price1=" & GetVariable("price1") & "&price2=" & GetVariable("price2")
                    
                    rs.pagesize=intPageSize
                    intCount=rs.RecordCount 
                    intPageCount=rs.pagecount
                    intSectionCount=(intPageCount - 1) \ intSectionSize + 1
                    if intCount>0 then
                        rs.AbsolutePage=page  
                    end if
                    %>

回复列表 (共4个回复)

沙发

第二段代码
<%
strCurrMenu="14753"
ThisPage=request.ServerVariables("URL")
strQuery=""
strTitle="所有新闻"
if GetVariable("class")<>"" then
    SourCode=conn.execute("Select c_code From web_news_class Where mn_id=" & strCurrMenu & " and id="&GetVariable("class"))(0)
    strQuery=strQuery & " And c_code Like '" & SourCode &"%'"
    strTitle=GetVariable("classname")
end if

if GetVariable("key")<>"" then
    strQuery=strQuery & " And (nTitle Like '%" & GetVariable("key") & "%' or nHtmlText like '%" & GetVariable("key") & "%' or nKey like '%" & GetVariable("key") & "%') "
    strTitle="搜索:" & GetVariable("key")
end if

'从这开始读数据
strSQL="Select * From v_web_news Where nAudit<>0 " & strQuery & " And mn_id=" & strCurrMenu & " Order by ID Desc"
rs.open strSQL,conn,1,1
'分页显示初始化
page=GetVariable("page")
if page="" then
    page=1
else
    page=Cint(page)
end if

Section=GetVariable("section")
if Section="" then
    Section=1
else
    Section=Cint(Section)
end if
'变量赋值
intPageSize=15        '每页显示记录数
intSectionSize=5        '多少页为一段,像GOOGLE一样
PrevSectionText="<FONT face=webdings>7</FONT>"        '上一段的链接文字
NextSectionText="<FONT face=webdings>8</FONT>"        '下一段的链接文字
PrevPageText="<FONT face=webdings>3</FONT>"            '上页的链接文字    
NextPageText="<FONT face=webdings>4</FONT>"            '下页的链接文字

strPageUrl="?class=" & GetVariable("class") & "&classname=" & GetVariable("classname") & "&key=" & GetVariable("key") & "&mnid=" & strCurrMenu

rs.pagesize=intPageSize
intCount=rs.RecordCount 
intPageCount=rs.pagecount
intSectionCount=(intPageCount - 1) \ intSectionSize + 1
if intCount>0 then
    rs.AbsolutePage=page 
end if 
%>

板凳

问题,我想调用 新闻到首页 产品调用了,但是如果调用新闻,把新闻那段代码复制到首页就回出现错误,
上面2个代码 只能用一个
怎么调用

新手

谢谢

3 楼

呵呵,老大,谁来花时间看这么一大段一大段的代码哦
不能更简单么 …… ^!^

4 楼


在调用新闻功能的时候,把它的ID直接指向哪一条的新闻ID就可以了,例如:strSQL="Select * From v_web_news Where nAudit<>0 " & strQuery & " And mn_id=" & strCurrMenu & " Order by ID Desc"
rs.open strSQL,conn,1,1
'分页显示初始化
page=GetVariable("page")
if page="" then
    page=1
else
    page=Cint(page)
end if
在这里中,你只要把mn_id=" & strCurrMenu & "改为特定的ID号就可以了,也不用复制太多的代码,就复制相应的代码即可

我来回复

您尚未登录,请登录后再回复。点此登录或注册