jandrews3 Posted August 10, 2008 Share Posted August 10, 2008 I tested the following code and it worked as expected: if ($var1 == 1 or $var2 == 1) {print "One or both of them was true.";} Shouldn't this also work? It's printing EVERY SINGLE line regardless of whether $m_set or $f_set are empty: $count = 0; while ($count <= $max){ if ($m_set[$count] == "" or $f_set[$count] == ""){print "<tr><td>".$student[$count]."-".$count."</td>";} if ($m_set[$count] == ""){print "<td>".$mother[$count]."</td>";} if ($f_set[$count] == ""){print "<td>".$father[$count]."</td></tr>";} $count++; } Link to comment https://forums.phpfreaks.com/topic/118976-solved-if-or/ Share on other sites More sharing options...
Fadion Posted August 10, 2008 Share Posted August 10, 2008 Post the whole code with the $m_set and $f_set values. They are arrays right? EDIT: Oh and your code should be better like: <?php for ($i=0;$i<= $max;$i++) { print "<tr>"; if ($m_set[$i] == "" or $f_set[$i] == ""){print "<td>".$student[$i]."-".$i."</td>";} if ($m_set[$i] == ""){print "<td>".$mother[$i]."</td>";} if ($f_set[$i] == ""){print "<td>".$father[$i]."</td>";} print "</tr>"; } ?> I removed "< tr>" and "< /tr>" from the conditionals, so ure sure u always display them. Using for() instead of while() is just a personal taste Link to comment https://forums.phpfreaks.com/topic/118976-solved-if-or/#findComment-612653 Share on other sites More sharing options...
jandrews3 Posted August 10, 2008 Author Share Posted August 10, 2008 Sorry! I'm an idiot! I wasn't reading my output right. It was functioning properly. Wish there was a cure for idiocy, 'cause I need a vaccine. Link to comment https://forums.phpfreaks.com/topic/118976-solved-if-or/#findComment-612655 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.