HTML帮助在结果集中显示多行

时间:2012-04-12 19:23:16

标签: java html

好的,我看了看,大笑,我有问题。这是我的代码的最后一部分,显示了演员的电影,我已经建立了一个SQL数据库,里面有这些信息。虽然当我作为网页显示时,我只看到每个演员有一部电影,其中一些电影中至少有三部有任何建议或帮助?希望这不是愚蠢的大声笑我对此很新。

<h3><FONT COLOR="B22222">Filmography</FONT></h3>
<%
newaid = request.getParameter("selectedName");

String queryFilm = "SELECT * FROM artist, movies, artistmovie WHERE  artistmovie.mid = movies.mid AND artist.aid = artistmovie.aid AND artist.aid = '"; 
    queryFilm += request.getParameter("selectedName") + "';";

ResultSet rsFilm = stm.executeQuery(queryFilm);

while(rsFilm.next())
{
    title = rsFilm.getString("title");
    studio = rsFilm.getString("studio");
    rlsdate = rsFilm.getString("rlsdate");
    role = rsFilm.getString("role");
    oscar = rsFilm.getInt("oscar");
    }

    out.println("<tr><td>&nbsp;</td><td>" + title + "</td>");
    out.println("<td>&nbsp;&nbsp;&nbsp;</td><td>(" + studio + "</a></td>"); 
    out.println("<td></td><td>" + rlsdate + ")</td>");  
    out.println("<td>&nbsp;&nbsp;</td><td>" + role + "</td>");
if (oscar == 0)
{
    out.println("<td>&nbsp;</td><td><br /></td>");
}
else
{
    out.println("<td>&nbsp;</td><td>Won oscar</td></tr>");
}
%>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

我的猜测是你在打印数据之前关闭了while语句。试试这个:

while(rsFilm.next())
{
    title = rsFilm.getString("title");
    studio = rsFilm.getString("studio");
    rlsdate = rsFilm.getString("rlsdate");
    role = rsFilm.getString("role");
    oscar = rsFilm.getInt("oscar");

    out.println("<tr><td>&nbsp;</td><td>" + title + "</td>");
    out.println("<td>&nbsp;&nbsp;&nbsp;</td><td>(" + studio + "</a></td>"); 
    out.println("<td></td><td>" + rlsdate + ")</td>");  
    out.println("<td>&nbsp;&nbsp;</td><td>" + role + "</td>");
}