Naveed Cheema Naveed Cheema - 2 months ago 6
PHP Question

how to set value using php inside <a></a> tag

Basically, I'm trying to set the title against the value which came from DB but when I make a PHP statement in inverted commas to set title the tag got disturbed. Any Suggestions ??

<?php
$Institute_Code=$_GET['Institute_Code'];
echo ?>
<td><a id="bookmark-this" value= "hi" href="#" title="<?php $Institute_Code ?>" >Bookmark This Page</a><td>

Answer

You aren't printing the $Institute_Code variable

You have...

 title="<?php $Institute_Code ?>"

You need to use one of these methods

     title="<?php echo $Institute_Code; ?>"

OR

     title="<?=$Institute_Code?>"

Also, the other echo ?> will cause an error, make that just ?>