Jump to content

[SOLVED] Loop not completely working...


Clinton

Recommended Posts

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???

Link to comment
Share on other sites

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."

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.