Search code examples
phphtmlmysqldatabasehref

Adding href in php from database


<ul> 
<li> Telephone number : <?php  echo $row[3]?> </li> 
<li> Website : <a href = "<?php  echo $row[4]?>" ></a> </li>
</ul>

Output screen

$row[4] represents the column in database that has the link to website. I'm trying this code to get href but it's not working for some reason. Any hints what am I doing wrong here?

If I echo it without making it an href then it's working fine. So my database connection is perfectly working.

Thanks in advance.


Solution

  • Well, you filled only the href attribute of the link. The text to be displayed must be put between the link tags:

    <a href="<?php echo $row[4]; ?>"><?php echo $row[4]; ?></a>