怎样循环实现?

a2048 2006-02-24 02:27:37
<%try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:internet");
Statement state=con.createStatement();
ResultSet rs0=state.executeQuery("select aa from a where ID='0'");
while(rs0.next())
{
%>
<table width="100%" border="0" bgcolor="blue" height="25">
<tr>
<td width="40%" height="200">区域 </td>
<td width="60%" height="200"><%= rs0.getString("aa")></td>
</tr>
</table>
<% }%>

一般
<td width="60%" height="200"><%= rs0.getString("aa")></td>
这个表格里是放一个数据的
如果现在查询出有18个或更多怎么把
<td width="60%" height="200"><%= rs0.getString("aa")></td>
这个表格里的数据控制在5个?如果多余5个就循环推下去?
例如:
上海
北京
区域 南京
浙江
厦门


上海
厦门
区域 浙江
南京
北京

........
...全文
177 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
a2048 2006-02-24
  • 打赏
  • 举报
回复
我要实现的象这样的效果。
http://www.rivieragolf.cn/8.htm
aywrenyue 2006-02-24
  • 打赏
  • 举报
回复
bitou(大鹏一日同风起,扶摇直上九万里)
思路正解
interpb 2006-02-24
  • 打赏
  • 举报
回复
可以实现吗
bitou 2006-02-24
  • 打赏
  • 举报
回复
我刚好有个这样的例子,用表格进行循环,请参照,如:

<table width="100%" border="0">
<%count = news_list.size();//记录条数
trcount = count/5+1;//计算tr的个数
for(int i=0;i<trcount;i++){
%>
<tr>
<%
int curcount = 5;
if((i+1)*5>count)
curcount = (count-i*5)%5;//每个tr 5个 td ,然后循环下去
for(int j=0;j<curcount;j++){
PropertyVO pvo = (PropertyVO)news_list.get(i*5+j);
%>
<td width="20%"><input type="checkbox" name="news" value="<%=pvo.getPropid()%>" <%=Constants.isChecked(nivo.getNews(),pvo.getPropid())%>><%=pvo.getPropname()%></td>
<%}%>
</tr>
<%}%>
</table>

你也可以用表格为单位进行循环
a2048 2006-02-24
  • 打赏
  • 举报
回复
我就要5个数据放在一个表格里。
interpb 2006-02-24
  • 打赏
  • 举报
回复
你这里怎么没条记录都用一个<table>
把你的意思说清楚

把你想的格式写清楚很好解决的

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧