Jump to content

Merge If Empty Code


Go to solution Solved by justlukeyou,

Recommended Posts

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
}
?>
Link to comment
https://forums.phpfreaks.com/topic/276084-merge-if-empty-code/
Share on other sites

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'] ; ?>
Link to comment
https://forums.phpfreaks.com/topic/276084-merge-if-empty-code/#findComment-1420700
Share on other sites

I think I decoded what he means :geek:

 

 

<?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 by PaulRyan
Link to comment
https://forums.phpfreaks.com/topic/276084-merge-if-empty-code/#findComment-1420702
Share on other sites

  • Solution

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 by justlukeyou
Link to comment
https://forums.phpfreaks.com/topic/276084-merge-if-empty-code/#findComment-1420707
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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