Search code examples
phphtmlhrefhtml-table

PHP/HTML appears and functions in Source view but not in browser?


I have a bit of my code that seems to work in source view, but doesn't appear in my browser?

It's a link within a table being generated by PHP echo. It looks like this in Source:

<td><a href=http://www.webaddresshere.com></a></td>

The code generating it is:

<td><a href=<?php echo htmlentities($row['website'], ENT_QUOTES, 'UTF-8'); ?></a></td>

And here is the full table it is within:

    <h3>Listings</h3>
<table cellpadding="10%" cellspacing="10%" width="100%">
<tbody align="left">
    <tr>
        <th></th>
        <th>Supplier</th>
        <th>Service</th>
        <th>Price</th>
        <th>Website</th>
        <th>Telephone</th>
    </tr>
    <?php foreach($rows as $row): ?>
        <tr>
            <td></td>
            <td><?php echo htmlentities($row['supplier'], ENT_QUOTES, 'UTF-8'); ?></td>
            <td><?php echo htmlentities($row['service'], ENT_QUOTES, 'UTF-8'); ?></td>
            <td><?php echo htmlentities($row['price'], ENT_QUOTES, 'UTF-8'); ?></td>
            <td><a href=http://<?php echo htmlentities($row['website'], ENT_QUOTES, 'UTF-8'); ?>></a></td>
            <td><?php echo htmlentities($row['telephone'], ENT_QUOTES, 'UTF-8'); ?></td>
        </tr>
        <tr>
        <td><br></td>
        </tr>
    <?php endforeach; ?>
</table>

Any ideas as to why it's doing this?

Thanks.


Solution

  • This is because there is no text in your link, so basically, nothing is being linked.

    <td><a href=<?php echo htmlentities($row['website'], ENT_QUOTES, 'UTF-8'); ?>Some Text Here For It To Be Clickable</a></td>