我把代码给帖上来吧:
<%
String id="";//id 是一个编号
String username="";
String password="";
String url="jdbc:odbc:NewSchoolArea2";
  try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    }
    catch(Exception e){out.println("驱动程序未找到!");}
    Connection con=DriverManager.getConnection(url,username,password);
    Statement conn=con.createStatement();
    ResultSet rs=conn.executeQuery("select * from 公告 order by 日期 DESC");
    if(rs.next())
    {%>
    <marquee onmouseover="this.stop()" onmouseout="this.start()" scrollamount="2" direction="up" >
    <%
    for(int i=0;i<20;i++)
     {%>
    <a href="admin/news.jsp;" target="_parent" class="STYLE126"> <%=("☆"+rs.getString("公告名"))%></a>
    <%    
![]()
 //上面的代码运行起来后,数据库中的公告名就全显示出来了.这时如果你点哪一条,那么就会转到admin/news.jsp去,news.jsp里就select 内容 where 编号=id.我就想知道,这个id怎么弄来,数据库中有 编号 这属性.
    try{
        if(!rs.next()){break;}
        }catch(Exception e){}
}}%>
谢谢各位!