justlukeyou Posted March 24, 2013 Share Posted March 24, 2013 Hi, I am trying to merge the empty code for 'skill3link' and 'skill3' but whatever I try doesn't seem to work. The code will only display the last empty row. In this case 'skill3'. Can anyone advise an alternative please or how to merge the two codes together. <?php endif; ?> <?php if (!empty($row['skill3link'])) : ?> <?php endif; ?> <?php if (!empty($row['skill3'])) : ?> <div class="eventskillscell"> <a href="/siteinfo/eventskillsquery.php?skill3=<?php echo $row['skill3link'] ; ?>" class='dealpagelink' > <?php echo $row['skill3'] ; ?> </a> </div> <?php endif; ?> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/276084-merge-if-empty-code/ Share on other sites More sharing options...
PaulRyan Posted March 24, 2013 Share Posted March 24, 2013 What are you expected results? What are your current results? What should the output look like? Quote Link to comment https://forums.phpfreaks.com/topic/276084-merge-if-empty-code/#findComment-1420698 Share on other sites More sharing options...
justlukeyou Posted March 24, 2013 Author Share Posted March 24, 2013 Hi, The plan is that it echoes the skill3link into a link around skill3. However it only echoes skill3 and not skill3link. I need something like this but cant get the right code. <?php if (!empty($row['skill3link'])) , (!empty($row['skill3'])) : ?> <?php endif; ?> <?php if (!empty($row['skill3link'])) : ?> <?php endif; ?> <?php if (!empty($row['skill3'])) : ?> <div class="eventskillscell"> <a href="/siteinfo/eventskillsquery.php?skill3=<?php echo $row['skill3link'] ; ?>" class='dealpagelink' > <?php echo $row['skill3'] ; ?> Quote Link to comment https://forums.phpfreaks.com/topic/276084-merge-if-empty-code/#findComment-1420700 Share on other sites More sharing options...
haku Posted March 24, 2013 Share Posted March 24, 2013 (edited) And the answers to PaulRyan's questions are? None of his questions referred to code. Edited March 24, 2013 by haku Quote Link to comment https://forums.phpfreaks.com/topic/276084-merge-if-empty-code/#findComment-1420701 Share on other sites More sharing options...
PaulRyan Posted March 24, 2013 Share Posted March 24, 2013 (edited) I think I decoded what he means <?PHP if(!empty($row['skill3link']) && !empty($row['skill3'])) { //### Echo content here } ?> *Edit: Why do you keep jumping in and out of the PHP tags? That looks really messy, and is quite hard to follow. Edited March 24, 2013 by PaulRyan Quote Link to comment https://forums.phpfreaks.com/topic/276084-merge-if-empty-code/#findComment-1420702 Share on other sites More sharing options...
haku Posted March 24, 2013 Share Posted March 24, 2013 You're a good man. When people can't be bothered to explain things in detail, particularly when they are even prodded with the questions they should answer to explain it in detail, I usually don't even look at their code (and didn't this time). Quote Link to comment https://forums.phpfreaks.com/topic/276084-merge-if-empty-code/#findComment-1420703 Share on other sites More sharing options...
Solution justlukeyou Posted March 24, 2013 Author Solution Share Posted March 24, 2013 (edited) Thanks, but the && command doesn't seem to work. I set up a test but the following set of code doesn't echo anything but without the && command it does work. <?PHP $query = mysql_query("SELECT skill1, skill2, skill3 FROM users "); while($row = mysql_fetch_array($query)) { if(!empty($row['skill3link']) && !empty($row['skill3'])) { echo $row['skill3'] ; } } ?>This works... <?PHP $query = mysql_query("SELECT skill1, skill2, skill3 FROM users "); while($row = mysql_fetch_array($query)) { if(!empty($row['skill3'])) { echo $row['skill3'] ; } } ?> Edited March 24, 2013 by justlukeyou Quote Link to comment https://forums.phpfreaks.com/topic/276084-merge-if-empty-code/#findComment-1420707 Share on other sites More sharing options...
PaulRyan Posted March 24, 2013 Share Posted March 24, 2013 Glad you fixed your issue, next time explain your problem better and we'll be able to offer better advice/help. Quote Link to comment https://forums.phpfreaks.com/topic/276084-merge-if-empty-code/#findComment-1420709 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.