日期:2014-05-18  浏览次数:20602 次

急!!如何实现内容的上移下移的排序功能
这是代码!
但有错误!能否帮忙修改一下!
在一个页面处理!
这是上移
  <a   href= "news_active_manage.jsp?active=up&Id= <%=Id%> "> <img   src= "pic/up.gif "   width= "11 "   height= "11 "     border= "0 "> </a>
这是下移
<a   href= "news_active_manage.jsp?active=down&Id= <%=Id%> "> <img   src= "pic/down.gif "   width= "11 "   height= "11 "   border= "0 "> </a>

这是处理

<%@   page   contentType= "text/html;   charset=utf-8 "   language= "java "   import= "java.sql.* "   %>
<jsp:useBean   id= "Condata "   scope= "page "   class= "connection.Condata "/>
<jsp:useBean   id= "chStr "   scope= "page "   class= "zhstring.Str "/>
<%
String   type=request.getParameter( "active ");
int   id=Integer.parseInt(request.getParameter( "Id "));

int   x_id=id+1;
int   rootid=0;
int   xrootid=0;

if(type.equals( "up "))
{
  ResultSet   rs1=Condata.executeQuery( "select   sortid   from   news_active   where   Id= ' "+id+ " ' ");
  ResultSet   rs2=Condata.executeQuery( "select   sortid   from   news_active   where   Id= ' "+x_id+ " ' ");
                if(rs1.next())
                        {
                                    rootid=rs1.getInt( "sortid ");
                                   
                          }
                if(rs2.next())
                        {
                                xrootid=rs2.getInt( "sortid ");
                             
                        }
            if   (rootid> 1)
                            {
                                        Condata.executeUpdate( "update   news_active   set   sortid= ' "+xrootid+   " '-1   where     Id= ' "+x_id+ ' ");
                                        Condata.executeUpdate( "update   news_active   set   sortid= ' "+rootid+   " '+1   where   Id= ' "+id+ ' ");