Would appreciate some assistance
Have pdf's uploaded to a database, want the user to be able to download/open them. Not a problem
<a href="<?php echo $row_Cal_list['entry_form']; ?>">Entry Form</a>
Works fine
Problem, I only want the link to show if there is an entry form available, if the field is empty then I would prefer it to be blank
Have this which works nicely.
<?php
if($row_Cal_list['entry_form'] != '')
{
echo $row_Cal_list['entry_form'];
}
?>
How do I put the two together, or is there a better way?
Am a dreamweaver user and obviously am no genius where php is concerned
Thanks in advance
return a value if field is not empty
Moderator: General Moderators
Re: return a value if field is not empty
try this:
<?php
if($row_Cal_list['entry_form'] != '')
{
echo "<a href='<?php echo $row_Cal_list['entry_form']; ?>'>Entry Form</a>";
}
?>
<?php
if($row_Cal_list['entry_form'] != '')
{
echo "<a href='<?php echo $row_Cal_list['entry_form']; ?>'>Entry Form</a>";
}
?>
Re: return a value if field is not empty
Thanks
Nice try, but does not work
Error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
any other ideas?
Thanks in advance
Nice try, but does not work
Error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
any other ideas?
Thanks in advance
Re: return a value if field is not empty
Some valid syntax to choose from:
Code: Select all
<?php if ($row_Cal_list['entry_form'] != ''): ?>
<a href="<?php echo $row_Cal_list['entry_form']; ?>">Entry Form</a>
<?php endif; ?>
<?php if ($row_Cal_list['entry_form'] != '') { ?>
<a href="<?php echo $row_Cal_list['entry_form']; ?>">Entry Form</a>
<?php } ?>
<?php if ($row_Cal_list['entry_form'] != '') {
?><a href="<?php echo $row_Cal_list['entry_form']; ?>">Entry Form</a><?php
} ?>
<?php
if ($row_Cal_list["entry_form"] != "") :
echo '<a href="', $row_Cal_list['entry_form'], '">Entry Form</a>';
printf('<a href="%s">Entry Form</a>', $row_Cal_list['entry_form']);
echo sprintf("<a href=\"%s\">Entry Form</a>", $row_Cal_list['entry_form']);
endif;
?>
<?php
if ($row_Cal_list['entry_form'] != '') {
echo "<a href=\"$row_Cal_list[entry_form]\">Entry Form</a>";
echo "<a href=\"{$row_Cal_list['entry_form']}\">Entry Form</a>";
echo "<a href=\"" . $row_Cal_list['entry_form'] . "\">Entry Form</a>";
echo '<a href="' . $row_Cal_list['entry_form'] . '">Entry Form</a>';
}
?>Re: return a value if field is not empty
Thankyou, will have to learn more about php
Your assistance is greatly appreciated.
Your assistance is greatly appreciated.