Clinton Posted February 12, 2009 Share Posted February 12, 2009 The code below works on the first go around but not completely on the 2+ go around: <?php $sql = "SELECT * FROM apply WHERE did = '$id' ORDER BY rname"; $rs = mysql_query($sql); $i=0; while($mrow = mysql_fetch_array($rs)) { $query = mysql_query("SELECT jid FROM apply WHERE did = '$id'"); $row = mysql_fetch_assoc($query); $jid = $row['jid']; $query = mysql_query("SELECT * FROM thelist WHERE id = '$jid'"); $row = mysql_fetch_assoc($query); $jtitle = $row['jtitle']; /// THIS ROW /// $cname = $row['cname']; /// AND THIS ROW DO NOT SHOW ON THE 2+ LOOPS /// extract($mrow); $applydate = date("Y-m-d", strtotime($applydate)); $bground = "#33AA00"; if (($i%2) == 0) $bground = "#0000BB"; $i++; ?> <tr bgcolor="<?php echo $bground; ?>"> <td> <?php echo $applydate; ?> </td> <td> <?php echo $jtitle; ?> </td> <td> <?php echo $cname; ?> </td> <td> <?php echo $closingdate; ?> </td> <td> <?php echo $status; ?> </td> <td><a href="astatus.php?did1=<?php echo $did; ?>&del=yes&id1=<?php echo $id; ?>" onclick="return confirmDelete();"> Delete </a></td> </td></tr> <?php } ?> Any idea why this might be happening??? Quote Link to comment Share on other sites More sharing options...
9three Posted February 12, 2009 Share Posted February 12, 2009 The problem is that you are incrementing if the condition is met. What if the condition is never met? Quote Link to comment Share on other sites More sharing options...
Clinton Posted February 12, 2009 Author Share Posted February 12, 2009 I'm not sure that's it. I'm incrementing the bgcolor so it divides itself and depending on the return will make my row either blue or green. That part is also working just fine. Quote Link to comment Share on other sites More sharing options...
9three Posted February 12, 2009 Share Posted February 12, 2009 You set the variable i to zero if (($i%2) == 0) $bground = "#0000BB"; $i++; ?> so because the first time it loops i matches zero. But what happens when the loop goes through again i is no longer zero. Quote Link to comment Share on other sites More sharing options...
Clinton Posted February 12, 2009 Author Share Posted February 12, 2009 Good question. I know the answer is around here somewhere but to save time I took it out and am still getting the problem. Quote Link to comment Share on other sites More sharing options...
Clinton Posted February 12, 2009 Author Share Posted February 12, 2009 Here's the answer to your question above: http://www.phpfreaks.com/forums/index.php/topic,232898.msg1080889.html#msg1080889 Quote Link to comment Share on other sites More sharing options...
9three Posted February 12, 2009 Share Posted February 12, 2009 Yes I knew the answer already. I'm trying to get you to actually try it for yourself. Quote Link to comment Share on other sites More sharing options...
Clinton Posted February 12, 2009 Author Share Posted February 12, 2009 Ok, well your original question was this, "What if the condition is never met?" and I guess my answer should have been, "If the condition is never met then the user would not be able to go to this page simply because the option would not exist on a prior page." Quote Link to comment Share on other sites More sharing options...
9three Posted February 12, 2009 Share Posted February 12, 2009 I can only go based on what you give me so if there was another page, I would not have known unless stated. Quote Link to comment Share on other sites More sharing options...
Clinton Posted February 12, 2009 Author Share Posted February 12, 2009 True... but the bgcolor and the incrementation had nothing to do with the original question. I can tell you it has something to do with this... $query = mysql_query("SELECT jid FROM apply WHERE did = '$id'"); $row = mysql_fetch_assoc($query); $jid = $row['jid']; ... I'm just not sure what yet. Quote Link to comment Share on other sites More sharing options...
Clinton Posted February 12, 2009 Author Share Posted February 12, 2009 I lied... the problem was with the first line. There is no ORDER BY rname. It's time to go to bed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.