ASP基础数据库

 <tr>
            <td height="40" colspan="5">   选择分类
              <select name="selClass" id="selClass" onChange="location='?<%="mnid=" & GetQueryString("mnid") & "&WindowName=" & GetQueryString("WindowName")%>&class=' + this.value">
                <option value="">所有分类</option>
                <%Sql="select id,c_name,c_code from web_news_class where mn_id="&GetVariable("mnid")&" order by c_code"
        set rsclass=conn.execute(sql)
        Do While Not rsclass.eof
   Level=(Len(rsclass(2))/4-1)*3
   Response.Write "<option value="""&rsclass(0)&""""
   Response.Write ">"
   If Len(rsclass(2))>4 Then Response.Write "├"
   Response.Write String(Level,"-")
   Response.Write rsclass(1)&"</option>"
   rsclass.movenext
  Loop
  rsclass.close%>
              </select></td>
          </tr>

<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<%
         strSQL="Select top 15 * From web_news  where nClass in (Select id from web_news_class where c_name='最新消息') Order by ID Desc"
            Set rs=Server.CreateObject("ADODB.RecordSet")
            rs.open strSQL,conn,1,1
         while not rs.eof
        %>
                      <tr>
                        <td>·<a href="news.asp?id=<%=rs("id")%>" target="_blank"><%=rs("nTitle")%></a></td>
                      </tr>
       <%
        rs.movenext
        wend
        set rs=nothing
        %>
                    
</table>


<%
strQueryString="&mnid=" & GetQueryString("mnid") & "&class=" & GetQueryString("class") & "&WindowName=" & GetQueryString("WindowName")
strQuery=" Where mn_id=" & GetQueryString("mnid")
strClass=GetQueryString("class")
if strClass<>"" then
 SourCode=conn.execute("Select c_code From web_news_class Where mn_id=" & GetQueryString("mnid") & " and id="&strClass)(0)
 strQuery=strQuery & " And c_code Like '" & SourCode &"%'"
end if

'从这开始读数据
strSQL="Select * From v_web_news " & strQuery &" 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=10  '每页显示记录数
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="?t=" & strQueryString

rs.pagesize=intPageSize
intCount=rs.RecordCount
intPageCount=rs.pagecount
intSectionCount=(intPageCount - 1) / intSectionSize + 1
if intCount>0 then
 rs.AbsolutePage=page 
end if
%>
<%
   '循环输出
   for i=1 to intPageSize
   if rs.eof then exit for
   if i mod 2=0 then
    strColor="#eeeeee"
   else
    strColor="#f9f9f9"
   end if
   %>
          <tr bgcolor="<%=strColor%>">
            <td width="5%" align="center" bgcolor="<%=strColor%>"><input name="id" type="checkbox" id="id" value="<%=trim(rs("id"))%>"></td>
            <td width="53%"><%=trim(rs("nTitle"))%></td>
            <td width="10%" align="center"><%=trim(rs("nAuthor"))%></td>
            <td width="17%" align="center"><%=trim(rs("nTime"))%></td>
            <td align="center">[<a href="?id=<%=trim(rs("id"))%>&action=dele<%=strQueryString%>">删除</a>][<a href="javascript:" onClick="window.open('edit.asp?id=<%=trim(rs("id"))%><%=strQueryString%>','','toolbar=yes,resizable=yes')">修改</a>]</td>
          </tr>
          <%
    rs.movenext
    next
    %>
<tr>
      <td bgcolor="#669900"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td align="right"> <font color="#FFFFFF">共有<%=intCount%>记录,分<%=intPageCount%>页,当前页<%=Page%>,每页显示<%=intPageSize%>条记录
              <%
   '计算每一段的开始页
   intStarPage=(Section-2) * intSectionSize + 1
   '前一段
   if Section<=1 then
    response.Write(PrevSectionText & " ")
   else
    response.Write("<a href='" & strPageUrl & "&page=" & intStarPage & "&section=" & Section-1 & "'>" & PrevSectionText & "</a> ")
   end if
   
   '显示页码列表
   response.Write("第")
   intStarPage=(Section-1) * intSectionSize + 1
      for p=intStarPage to intStarPage + intSectionSize - 1
    if p > intPageCount then exit for
    if p=page then
        response.Write("<strong>[" & p & "]</strong> ")
    else
        response.Write("<a href='" & strPageUrl & "&page=" & p & "&section=" & Section & "'>[" & p & "]</a> ")
    end if 
      next
   response.Write("页")
   '后一段
   intStarPage=(Section) * intSectionSize + 1
   if Section>=intSectionCount then
    response.Write(" " & NextSectionText)
   else
    response.Write(" <a href='" & strPageUrl & "&page=" & intStarPage & "&section=" & Section+1 & "'>" & NextSectionText & "</a> ")
   end if
    %>
              <select name="page" size="1" onChange="window.location='<%=strPageUrl & "&section="%>' + (Math.floor((parseInt(this.value)-1)/<%=intSectionSize%>)+1) + '<%="&page="%>' + this.value">
                <option value="<%=page%>" selected>第<%=page%>页</option>
                <%
       for i=1 to rs.pagecount
     %>
                <option value="<%=i%>" >第<%=i%>页</option>
                <%
       next
      %>
              </select>
              </font>   </td>
          </tr>
        </table></td>
    </tr>

 

 <%

 tmpid=GetVariable("id")
 
 if tmpid="" then
  title=""
  author=Session("RealName")
  original=""
  content=""
  classid=GetQueryString("class")
 else
  '取指定ID的新闻出来编辑
 strSQL="select * from web_news where ID=" & tmpid
 
  set rs=server.CreateObject ("ADODB.Recordset")
  rs.open strSQL,conn,1,1
  tmpid=trim(rs("ID"))
  title=Server.HTMLEncode(trim(rs("nTitle")))
  author=trim(rs("nAuthor"))
  original=trim(rs("nOriginal"))
  content=Server.HTMLEncode(trim(rs("nHtmlText")))
  classid=trim(rs("nClass"))
  rs.close
 end if

 HtmlEditContent = content
 EditorHeight = "90%"

%>
<form action="save.asp?mnid=<%=GetQueryString("mnid")%>&WindowName=<%=GetQueryString("WindowName")%>" method="post" name="newform" target="BackFrame" id="newform" onSubmit="return CheckForm(this)">
  <table width="100%" height="100%" border="0" cellpadding="2" cellspacing="1" bgcolor="#336600">
    <tr>
      <td height="26" colspan="2" bgcolor="#669900"> <font color="#FFFFFF">::发表<%=GetQueryString("WindowName")%></font></td>
    </tr>
    <tr bgcolor="#eeeeee">
      <td height="26" align="right">新闻分类:</td>
      <td height="26"> <select name="selClass" id="selClass">
   <option value="">请选择...</option>
          <%Sql="select id,c_name,c_code from web_news_class where mn_id="&GetVariable("mnid")&" order by c_code"
        set rsclass=conn.execute(sql)
        Do While Not rsclass.eof
   Level=(Len(rsclass(2))/4-1)*3
   Response.Write "<option value="""&rsclass(0)&""""
   Response.Write ">"
   If Len(rsclass(2))>4 Then Response.Write "├"
   Response.Write String(Level,"-")
   Response.Write rsclass(1)&"</option>"
   rsclass.movenext
  Loop
  rsclass.close%>
        </select></td>
    </tr>
    <tr bgcolor="#eeeeee">
      <td width="11%" height="26" align="right">标 题:</td>
      <td height="26">
        <input name="Title" type="text" class=bginput id="Title" value="<%=title%>" size="50" maxlength="100">
        (必填)
        <input name="newid" type="hidden" id="newid" value="<%=tmpid%>" >
      </td>
    </tr>
    <tr bgcolor="#F9F9F9">
      <td height="26" align="right">作 者:</td>
      <td height="26">
        <input name="Author" type="text" class=bginput id="Author" value="<%=author%>"></td>
    </tr>
    <tr bgcolor="#eeeeee">
      <td height="26" align="right">来 源:</td>
      <td height="26">
        <input name="Original" type="text" class=bginput id="Original" value="<%=original%>"></td>
    </tr>
    <tr align="center" bgcolor="#D4D0C8">
      <td height="100%" colspan="2" valign="middle">
        <table width="100%" height="100%" border=1 cellpadding="0" cellspacing="0"  bordercolor=gray >
          <tr>
            <td align=center>
    <textarea name="content" style="display:none"><%=HtmlEditContent%></textarea><input type="hidden" name="content1">
                    <iframe ID="eWebEditor1" src="../editor/ewebeditor.asp?id=content&style=standard" frameborder="0" scrolling="no" width="100%" HEIGHT="100%">
                    </iframe>
            </td>
          </tr>
        </table>
      </td>
    </tr>
    <tr align="center" bgcolor="#eeeeee">
      <td height="40" colspan="2"> <table width="100%" border="0" cellspacing="0" cellpadding="5">
          <tr>
            <td align="center"> <input name="submit1" type=submit class=button value=" 保 存 " >
               
              <input name="YL" type=button class=button value=" 关 闭 " onClick="window.close()"></td>
          </tr>
        </table></td>
    </tr>
  </table>
 
</form>

 

<!--功能修改新增删除-->
conn.execute strsql,0,1
conn.close
set conn=nothing

 

 

 

 

 

 

 


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值