Reputation: 167
Goal:
Instead of showing simple YES or NO.
If value is found in record, show hyperlink with that value or else show text "No"
How to modify below code for this purpose:
<?php echo $row_RecordsetContacts['propertyFile'] ? '<strong>Yes</strong></br>' : 'No</br>'; ?>
<a href="propfiles/<?php echo $row_RecordsetContacts['propertyFile']; ?>">View</a>
</td>
Upvotes: 0
Views: 47
Reputation: 3450
Try the following code:
<?php
$prop = $row_RecordsetContacts['propertyFile'];
if(empty($prop)) {
echo "No";
} else {
echo "<a href='propfiles/$prop'>View</a>";
}
?>
Upvotes: 1
Reputation: 1146
<?php
$file = $row_RecordsetContacts['propertyFile']; # for readability only
if ($file)
{
?><a href="propfiles/<?= $file ?>">View</a><?php
}
else
{
?>No<?php
}
I also suggest to avoid mixing echo
and HTML markup. In 99% cases it makes the code better for understanding.
Upvotes: 1