Jump to content

Merge If Empty Code


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.

Link to comment
https://forums.phpfreaks.com/topic/276084-merge-if-empty-code/#findComment-1420702
Share on other sites

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'] ;
}
}

?>
Link to comment
https://forums.phpfreaks.com/topic/276084-merge-if-empty-code/#findComment-1420707
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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