PHP / HTML出现并在Source视图中运行,但在浏览器中没有?

时间:2014-10-29 13:08:35

标签: php html href html-table

我的一些代码似乎在源代码视图中有效,但是我的浏览器中没有这些代码?

它是由PHP echo生成的表中的链接。它在Source中看起来像这样:

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

生成它的代码是:

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

以下是它所在的完整表格:

    <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>

关于它为什么要这样做的任何想法?

感谢。

3 个答案:

答案 0 :(得分:3)

看这里 -

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

链接中没有文字。

答案 1 :(得分:0)

这是因为您的链接中没有文字,所以基本上没有任何内容被链接。

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

答案 2 :(得分:0)

<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'); ?>">Link</a></td>
            <td><?php echo htmlentities($row['telephone'], ENT_QUOTES, 'UTF-8'); ?></td>
        </tr>
        <tr>
            <td><br></td>
        </tr>
    <?php endforeach; ?>
</table>

点击此处我添加了一个文本“链接”,单击可见:)。