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
https://forums.phpfreaks.com/topic/144880-solved-loop-not-completely-working/
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."

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.