0

好的,我已经看了又看,哈哈,我遇到了问题。这是我的代码的最后一部分,显示演员的电影,我已经建立了一个 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>
4

1 回答 1

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>");
}
于 2012-04-12T19:26:02.523 回答