Re: If statement duplicating mysql records?

From: Date: Thu, 21 Jun 2007 17:42:07 +0000
Subject: Re: If statement duplicating mysql records?
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-257572@lists.php.net to get a copy of this message
Jason Pruim wrote: > > > The code I had worked out, originally was something along the lines of: > > if($row[5] =="Level1") ( > echo "<TR><TD bgcolor=".$Level1.">$row[0] </td>"; > echo "<td bgcolor=".$Level1.">$row[1] </td>"; > echo "<td bgcolor=".$Level1."><A > href='$row[2]'>Instructions</A></td>"; > echo "<TD bgcolor=".$Level1."><A > href='update.php?taskid=$row[0]'>Click here!</A>"; > } > > if($row[5] =="Level2"){ > echo "<TR><TD bgcolor=".$Level2.">$row[0] </td>"; > echo "<td bgcolor=".$Level2.">$row[1] </td>"; > echo "<td bgcolor=".$Level2."><A > href='$row[2]'>Instructions</A></td>"; > echo "<TD bgcolor=".$Level2."><A > href='update.php?taskid=$row[0]'>Click here!</A>"; > > { > else > { > echo "<TR><TD bgcolor=".$unclassified.">$row[0] </td>"; > echo "<td bgcolor=".$unclassified.">$row[1] </td>"; > echo "<td bgcolor=".$unclassified."><A > href='$row[2]'>Instructions</A></td>"; > echo "<TD bgcolor=".$unclassified."><A > href='update.php?taskid=$row[0]'>Click here!</A>"; > > } > > and what would happen is if $row[5] =="Level1" it would change the color > to yellow, but then it would also display another line of the same info > that would have the $unclassified color assigned to it. Ahh, this is different from your original post. You have TWO if statements here. So when $row[5] = "Level1", it was satisfying the first IF statement and then falling into the ELSE of the second IF statement. Makes sense to me now why it was failing. Roberto

« previous php.general (#257572) next »