There are 4 ways of producing this output.
- Drop out of php mode at the start of the html document and only output the dynamic parts of the html document using php code. You can use php’s short open echo tag
<?=
and leave out the closing ; right before a closing php tag ?>
, so that echoing a variable looks like <?=$var?>
- Echo each individual piece of the output. This would take 5 echo statements.
- Put the variable(s) inside of an overall double-quoted string. Associative array elements require putting {} around the variable in the string so that php knows where the variable starts and ends. This will likely clear up the syntax errors you are getting.
- Use string concatenation to build the output. This results in the most error prone syntax due to all the extra quotes and concatenation dots.
Method #1 is the preferred use.
Also, you need to apply htmlentities() to any dynamic value you are outputting in a html context to help prevent cross site scripting.
<?php
// main php code for the page
// start of html document
?>
<!-- at the point of producing the link -->
<a href="mailto:<?=htmlentities($row['emailadd'])?>"><?=htmlentities($row['emailadd'])?></a>