simon551 Posted June 10, 2008 Share Posted June 10, 2008 I'm racking my brain on this all day. Can you see a problem with my code? Basically, I'm echoing out some info about each account. And then echoing out details related to that account, so I'm creating two loops to run through it all. This is an intranet admin stuff site. There are a couple problems that are happening: the data doesn't match up to the record when it echoes out (something wrong with the loop) and the inside loop table's width starts out very wide (2-3x times the screen width) and then gradually through each loop gets smaller until it's too small and stops showing up at all. I really appreciate it if you can offer me a nugget... </head> <body> <div id="main"> <table width="375"> <?php //start first loop: count employees do { $cellType=$row_cells_countEmp['cellType']; echo $cellType; ?> <tr> <td><strong><?php echo $row_cells_countEmp['employee'] ?></strong></td> </tr> <tr> <td>Plan Type: <?php echo $row_cells_countEmp['cellType'] ?></td> </tr> <tr> <td>Stipend Amount: <?php echo $row_cells_countEmp['stipendAmt'] ?></td> </tr> <tr> <td><a href="cell_new.php">edit</a></td> </tr> <tr> <td> <table width="250" align="center"> <tr class="tableheader"> <th width="200">Account</th> <th width="50">Amount </th> </tr> <?php $cellPlanId=$row_cells_countEmp['cellPlanId']; $query_cell1 = "SELECT contract_cellDets.cellDetId, contract_cellDets.contractID, contract_cellDets.perc, contract_cellDets.cAmount, CONCAT(tblclients.clientName,' - ',tbldivisions.division) AS contract FROM contract_cellDets INNER JOIN cell_plans ON contract_cellDets.cellPlanId = cell_plans.cellPlanId INNER JOIN contracts ON contract_cellDets.contractId=contracts.contractId INNER JOIN tblclients ON contracts.clientId=tblclients.clientId INNER JOIN tbldivisions on contracts.divisionID=tbldivisions.DivID WHERE contract_cellDets.cellPlanId =$cellPlanId ".$hrAdminCriteria.$planTypeCriteria; $cell1 = mysql_query($query_cell1, $conn_org) or die($query_cell1.mysql_error()); $row_cell1 = mysql_fetch_assoc($cell1); $tot=0; $totPerc=0; //start second loop inside first. echo out details from query do { ?> <tr class="d0" > <td><?php echo $row_cell1['contract']; ?></td> <td><?php if ($cellType=="personal plan") { $amount=(($row_cell1['perc'])*100).'%'; } if ($cellType=="company plan") { $amount= DoFormatCurrency($row_cell1['cAmount'], 2, '.', ',', '$'); } echo $amount; ?> </td> </tr> <?php $tot+=$row_cell1['cAmount']; $totPerc+=$row_cell1['perc']; //end inside loop } while ($row_cell1 = mysql_fetch_assoc($cell1)); ?> <tr class="d2"> <td><strong>Total <?php echo $emp;?></strong></td> <td><strong> <?php if ($cellType=="personal plan") { $percentage=(($totPerc)*100); echo $percentage.'%'; } if ($cellType=="company plan") { echo DoFormatCurrency($tot, 2, '.', ',', '$'); } ?></strong> </td> </tr> <?php //end first loop } while ($row_cells_countEmp = mysql_fetch_assoc($cells_countEmp)); ?> </table> </td> </tr> </table> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/109660-solved-strange-loop-results/ Share on other sites More sharing options...
DyslexicDog Posted June 10, 2008 Share Posted June 10, 2008 Can you post the output from webserver? Link to comment https://forums.phpfreaks.com/topic/109660-solved-strange-loop-results/#findComment-562648 Share on other sites More sharing options...
simon551 Posted June 11, 2008 Author Share Posted June 11, 2008 sorry. posting here made my brain come alive I think I have it fixed. I wasn't closing the table row/td/table inside the loop. argh. thanks! Link to comment https://forums.phpfreaks.com/topic/109660-solved-strange-loop-results/#findComment-562676 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.