jeff5656 Posted June 4, 2009 Share Posted June 4, 2009 The code inside else never gets run, even if the two else statements are fale. For example if $pulmonologist has a name, the else statement should run but it doesn't. Thanks while ($row = mysql_fetch_assoc ($results)) { if ($pulmonologist == '') echo ""; elseif ($pulmonologist == 'none') echo ""; else { if ($row['sentemail'] == 'y') { echo "<img src='../consults/images/greencheck2.png' alt='greencheck' width='15' height='20' border='0'/>"; } ?> <a href="notify.php?action=edit&id=<?php echo $row['id_incr']; ?>"><img src="../consults/images/notify.jpg" alt="Notify Doc" width="80" height="20" border="0" /></a> <?php } ?> </td> </tr> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/160909-solved-else-code-not-executing/ Share on other sites More sharing options...
gevans Posted June 4, 2009 Share Posted June 4, 2009 Check yor values, echo $pulmonologist and $row['sentemail'] Chck they are wht you expected. check for mysql errors. Quote Link to comment https://forums.phpfreaks.com/topic/160909-solved-else-code-not-executing/#findComment-849177 Share on other sites More sharing options...
SuperBlue Posted June 4, 2009 Share Posted June 4, 2009 You are missing some curly brackets, in your php else if which could course the error. I.e. if ($pulmonologist == '') { echo ""; } elseif ($pulmonologist == 'none') { echo ""; } Quote Link to comment https://forums.phpfreaks.com/topic/160909-solved-else-code-not-executing/#findComment-849191 Share on other sites More sharing options...
kickstart Posted June 4, 2009 Share Posted June 4, 2009 Hi Looks like $pulmonologist is set up prior to the loop, and so if it is ever blank or "none" then nothing useful in the loop will be output. Also if anything is output then you send a </td> and a </tr> without ever sending their opening equivalents. Could be worth posting the full code of that loop if that is just an edited fragment. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/160909-solved-else-code-not-executing/#findComment-849199 Share on other sites More sharing options...
.josh Posted June 4, 2009 Share Posted June 4, 2009 You are missing some curly brackets, in your php else if which could course the error. I.e. You do not need to wrap brackets around it if it's only one line of code being executed. His code is syntactically correct. As gevans mentioned, echo $pulmonologist to see if it contains what you are expecting it to contain. Quote Link to comment https://forums.phpfreaks.com/topic/160909-solved-else-code-not-executing/#findComment-849203 Share on other sites More sharing options...
taquitosensei Posted June 4, 2009 Share Posted June 4, 2009 you could also shorten that a little if ($pulmonologist == '' || $pulmonologist=='none') echo ""; else { if ($row['sentemail'] == 'y') { echo "<img src='../consults/images/greencheck2.png' alt='greencheck' width='15' height='20' border='0'/>"; } ?> <a href="notify.php?action=edit&id=<?php echo $row['id_incr']; ?>"><img src="../consults/images/notify.jpg" alt="Notify Doc" width="80" height="20" border="0" /></a> <?php } ?> </td> </tr> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/160909-solved-else-code-not-executing/#findComment-849217 Share on other sites More sharing options...
Maq Posted June 4, 2009 Share Posted June 4, 2009 Please properly format and indent your code, it makes debugging much easier. Quote Link to comment https://forums.phpfreaks.com/topic/160909-solved-else-code-not-executing/#findComment-849226 Share on other sites More sharing options...
jeff5656 Posted June 4, 2009 Author Share Posted June 4, 2009 Thanks. I needed to do $row['pulmonologist'] instead of $pulmonologist. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/160909-solved-else-code-not-executing/#findComment-849260 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.