Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Help with nested while loops.

    Hi Need some help with my nested loops. The problem is when the page loads the loop runs and produce 6 tables instead of 3 for each loop . I know the code looks messy and i'll work on the look and feel but its just functionality im after at this point.
    Code:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    	pageEncoding="ISO-8859-1"%>
    <%@ page import="java.sql.*"%>
    <%@ page import="dbProcs.Getter"%>
    <%@ page import="dbProcs.Setter"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>MY &middot; LEAGUES</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    
    <!-- Le styles -->
    <link href="bootstrap.css" rel="stylesheet">
    <style type="text/css">
    body {
    	padding-top: 20px;
    	padding-bottom: 40px;
    }
    
    /* Custom container */
    .container-narrow {
    	margin: 0 auto;
    	max-width: 700px;
    }
    
    .container-narrow>hr {
    	margin: 30px 0;
    }
    
    /* Main marketing message and sign up button */
    .jumbotron {
    	margin: 60px 0;
    	text-align: center;
    }
    
    .jumbotron h1 {
    	font-size: 72px;
    	line-height: 1;
    }
    
    .jumbotron .btn {
    	font-size: 21px;
    	padding: 14px 24px;
    }
    
    /* Supporting marketing content */
    .marketing {
    	margin: 60px 0;
    }
    
    .marketing p+h4 {
    	margin-top: 28px;
    }
    </style>
    <link href="bootstrap-responsive.css" rel="stylesheet">
    
    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
          <script src="../assets/js/html5shiv.js"></script>
        <![endif]-->
    
    <!-- Fav and touch icons -->
    <link rel="apple-touch-icon-precomposed" sizes="144x144"
    	href="../assets/ico/apple-touch-icon-144-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="114x114"
    	href="../assets/ico/apple-touch-icon-114-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="72x72"
    	href="../assets/ico/apple-touch-icon-72-precomposed.png">
    <link rel="apple-touch-icon-precomposed"
    	href="../assets/ico/apple-touch-icon-57-precomposed.png">
    <link rel="shortcut icon" href="../assets/ico/favicon.png">
    </head>
    
    <body>
    
    	<div class="container-narrow">
    
    		<div class="masthead">
    			<ul class="nav nav-pills pull-right">
    				<li class="active">
    				<li><a href="standings.jsp">Your League</a></li>
    				<li><a href="LogoutServlet">Logout</a></li>
    			</ul>
    			<h3 class="muted">MY LEAGUES</h3>
    		</div>
    
    		<hr>
    
    		<div class="jumbotron">
    			<h1>
    				Welcome
    				<%
    				HttpSession ses = request.getSession(true);
    				out.println(ses.getAttribute("name"));
    			%>
    			</h1>
    			<p class="lead">Select from the leagues below and enjoy!!!</p>
    			<p>
    			<form method="post" action="Join">
    				<label class="checkbox inline"> <input type="checkbox"
    					id="inlineCheckbox1" value="1">Table Tennis
    				</label> <label class="checkbox inline"> <input type="checkbox"
    					id="inlineCheckbox2" value="2">Darts
    				</label> <label class="checkbox inline"> <input type="checkbox"
    					id="inlineCheckbox3" value="3">Pool
    				</label> <a class="btn btn-large btn-success" name="submit">Sign up
    					today</a>
    
    			</form>
    		</div>
    
    		<hr>
    
    		<div class="row-fluid marketing">
    			<div class="span6">
    				<%
    					if (ses.getAttribute("admin") != null) {
    				%>
    
    				<div class="accordion" id="accordion2">
    					<div class="accordion-group">
    						<div class="accordion-heading">
    							<a class="accordion-toggle" data-toggle="collapse"
    								data-parent="#accordion2" href="#collapseOne"> Collapsible
    								Group Item #1 </a>
    						</div>
    						<div id="collapseOne" class="accordion-body collapse in">
    							<div class="accordion-inner">
    								<table width="100%" border="0" cellspacing="0" cellpadding="0">
    									<tr valign="top">
    										<td id="column1">
    											<form method="post" action="Matches">
    												<table id="tableSelect" class="row" width="100%" border="1"
    													cellspacing="0" cellpadding="0">
    													<caption align="top">League Management</caption>
    													<thead>
    														<tr>
    															<th>Select</th>
    															<th>Leagues</th>
    															<th>No Players in League</th>
    														</tr>
    													</thead>
    													</td>
    													<%
    														String ApplicationRoot = getServletContext().getRealPath("");
    															//ResultSet rs1 = Setter.makeMatches(ApplicationRoot, tourid, userid);
    															ResultSet rs = Getter.findSubs(ApplicationRoot);
    
    															while (rs.next()) {
    													%>
    
    													<tr>
    
    														<td><input name="group1" id="" type="radio"
    															value="<%=rs.getString(3)%>"></td>
    														<td width="50px" valign="top" bgcolor="#d2d8c7"><%=rs.getString(1)%></td>
    														<td width="50px" valign="top" bgcolor="#d2d8c7"><%=rs.getString(2)%></td>
    
    													</tr>
    
    													<%
    														}
    													%>
    													<input type="submit" value="Start League">
    
    												</table>
    											</form>
    											</div>
    											</div>
    											</div>
    											<%
    												}
    
    												else {
    											%> <%
     	String ApplicationRoot = getServletContext().getRealPath("");
    
     		ResultSet rs = Getter.findTour(ApplicationRoot, ses
     				.getAttribute("stamp").toString());
     		//Getting the result set from procedure call
     		while (rs.next()) {
     			ResultSet rs1 = Getter.verifyMatches(ApplicationRoot, ses
     					.getAttribute("stamp").toString());
     			ResultSet rs2 = Getter.getNoScoreMatches(ApplicationRoot,
     					ses.getAttribute("stamp").toString());
     %>
    											<div class="accordion" id="accordion2">
    												<div class="accordion-group">
    													<div class="accordion-heading">
    														<a class="accordion-toggle" data-toggle="collapse"
    															data-parent="#accordion2" href="#collapseOne">
    															Collapsible Group Item #2 </a>
    													</div>
    													<div id="collapseOne" class="accordion-body collapse in">
    														<div class="accordion-inner">
    															<table width="100px" border="1" cellspacing="0"
    																cellpadding="0">
    																<caption align="top">Matches to be verified</caption>
    																<thead>
    																	<tr>
    
    																		<th>Player1</th>
    																		<th>Score1</th>
    																		<th>Player2</th>
    																		<th>Score2</th>
    
    																	</tr>
    																</thead>
    
    
    
    
    																<%
    																	while (rs1.next()) {
    																%>
    																<form method="post" action="ValidateScores">
    																	<tr>
    																		<td width="50px" valign="top" bgcolor="#d2d8c7"><%=rs1.getString(1)%></td>
    																		<td width="50px" valign="top" bgcolor="#d2d8c7"><%=rs1.getString(3)%></td>
    																		<td width="50px" valign="top" bgcolor="#d2d8c7"><%=rs1.getString(2)%></td>
    																		<td width="50px" valign="top" bgcolor="#d2d8c7"><%=rs1.getString(4)%></td>
    																		<td><input type="hidden" name="match"
    																			value="<%=rs1.getString(5)%>"><input
    																			type="submit" value="Verify match"></td>
    																		<%-- <td width="50px" valign="top" bgcolor="#d2d8c7"><%=rs1.getString(2)%></td> --%>
    																</form>
    																</tr>
    															</table>
    
    															<%
    																}
    															%>
    														
    										</td>
    									<tr>
    
    										<table width="100px" border="0" cellspacing="0"
    											cellpadding="0">
    											<caption align="top">Matches to be scored</caption>
    											<thead>
    												<tr>
    
    
    													<th>Player1</th>
    													<th>vs</th>
    													<th>Player2</th>
    													<th>S1</th>
    													<th>S2</th>
    
    												</tr>
    											</thead>
    
    
    
    											<%
    												while (rs2.next()) {
    											%>
    											<form method="post" action="Score">
    												<tr>
    													<td width="50px" valign="top" bgcolor="#d2d8c7"><%=rs2.getString(1)%></td>
    													<td bgcolor="#d2d8c7">vs</td>
    													<td width="50px" valign="top" bgcolor="#d2d8c7"><%=rs2.getString(2)%></td>
    													<td><input type="text" width="50px" name="player1"></td>
    													<td><input type="text" width="50px" name="player2"></td>
    													<input type="hidden" name="match"
    														value="<%=rs2.getString(3)%>">
    													<td><input type="submit" value="Submit score"></td>
    												</tr>
    											</form>
    										</table>
    									</tr>
    
    									<%-- <td width="50px" valign="top" bgcolor="#d2d8c7"><%=rs1.getString(2)%></td> --%>
    									<%
    										}
    									%>
    
    
    								</table>
    							</div>
    						</div>
    					</div>
    
    					<%
    						}
    					%>
    
    
    					<%
    						}
    					%>
    				</div>
    
    				<div class="span6">
    					<h4>Table Tennis</h4>
    					<p>
    						<img src="images/tabletennnis.jpg" class="img-rounded" />
    					</p>
    
    					<h4>Darts</h4>
    					<p>
    						<img src="images/darts.jpg" alt="" width="310" height="130"
    							class="img-rounded" />
    					</p>
    
    					<h4>Pool</h4>
    					<p>
    						<img src="images/pool.jpg" alt="" width="310" height="130"
    							class="img-rounded" />
    					</p>
    				</div>
    			</div>
    
    			<hr>
    
    			<div class="footer">
    				<p>&copy;John Clarke 2013</p>
    			</div>
    
    		</div>
    		<!-- /container -->
    
    		<!-- Le javascript
        ================================================== -->
    		<!-- Placed at the end of the document so the pages load faster -->
    		<script src="../assets/js/jquery.js"></script>
    		<script src="../assets/js/bootstrap-transition.js"></script>
    		<script src="../assets/js/bootstrap-alert.js"></script>
    		<script src="../assets/js/bootstrap-modal.js"></script>
    		<script src="../assets/js/bootstrap-dropdown.js"></script>
    		<script src="../assets/js/bootstrap-scrollspy.js"></script>
    		<script src="../assets/js/bootstrap-tab.js"></script>
    		<script src="../assets/js/bootstrap-tooltip.js"></script>
    		<script src="../assets/js/bootstrap-popover.js"></script>
    		<script src="../assets/js/bootstrap-button.js"></script>
    		<script src="../assets/js/bootstrap-collapse.js"></script>
    		<script src="../assets/js/bootstrap-carousel.js"></script>
    		<script src="../assets/js/bootstrap-typeahead.js"></script>
    </body>
    </html>

  • #2
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,755
    Thanks
    41
    Thanked 191 Times in 190 Posts
    if the problem is in Javascript, we need to see the javascript files, and this needs to move to the javascript forum... if these loops are in Java, then we need to see the server side code.... either way the html mark-up tells us absolutely nothing

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •