简体   繁体   English

HTML表格内的`iframe`

[英]`iframe` inside an HTML table

I am displaying some data from a database into my cms, using tables ( tr , td ). 我正在使用表( trtd )将一些数据从数据库显示到我的cms中。

   <tr align="center">
        <td><?php echo $i++; ?></td>
        <td><?php echo $post_image; ?></td>
        <td><?php echo $post_title; ?></td>
        <td>
            <iframe width="100px" frameborder="0" id='inneriframe' scrolling=yes >
                <?php echo $post_description; ?>
            </iframe>
        </td>
        <td><a href="index.php?edit_football_news=<?php echo $post_id; ?>">Edit</a></td>
        <td><a href="includes/delete_football_news.php?delete_football_news=<?php echo $post_id; ?>">Delete</a></td>
    </tr>

Unfortunately the description php variable is not displayed at all inside my iframe . 不幸的是,描述php变量根本没有显示在我的iframe However, if I take out the iframe tag, everything works fine, and I can see all the stored values from the database. 但是,如果我取出iframe标记,则一切正常,并且可以从数据库中看到所有存储的值。

<tr align="center">
        <td><?php echo $i++; ?></td>
        <td><?php echo $post_image; ?></td>
        <td><?php echo $post_title; ?></td>
        <td><?php echo $post_description; ?></td>

        <td><a href="index.php?edit_football_news=<?php echo $post_id; ?>">Edit</a></td>
        <td><a href="includes/delete_football_news.php?delete_football_news=<?php echo $post_id; ?>">Delete</a></td>
    </tr>

So my main question is how to use iframes inside td s? 所以我的主要问题是如何在td s中使用iframe?

As I mentioned in comments (but gotten no response from). 正如我在评论中提到的(但没有得到回应)。

Taken from example #1: 取自示例1:

<iframe src="page.html" width="400" height="300">
   <p>Your browser does not support iframes.</p>
</iframe>

What you need to do is to remove the <?php echo $post_description; ?> 您需要做的是删除<?php echo $post_description; ?> <?php echo $post_description; ?> from the iframe and just do: <?php echo $post_description; ?>从iframe中执行以下操作:

<iframe src="file_for_iframe.php" width="100px" frameborder="0" id='inneriframe' scrolling=yes >

</iframe>

and have the variables inside file_for_iframe.php to be echo'd in there. 并将file_for_iframe.php内部的变量在其中回显。

That's how you'll get your iframe to show the contents "on screen" rather than in HTML source. 这样便可以使iframe在屏幕上而不是HTML源代码中显示内容。

If you had a look at your HTML source as I also mentioned in comments, you would indeed have seen the contents. 如果您查看一下我也在评论中提到的HTML源代码,您的确会看到其中的内容。

They're in there alright, but not being echo'd properly (on screen). 他们在那里,但是没有正确地回声(在屏幕上)。

The (and as an example) file_for_iframe.php file that I have stated above, will contain whatever content you wish to display. 我上面说过的(并作为示例) file_for_iframe.php文件将包含您希望显示的任何内容。

For example: 例如:

<?php 

echo $post_description = "Whatever is presently assigned to this...";

?>

Important note: 重要的提示:

echo $post_description = "x"; is valid syntax and you need to keep the echo for it. 是有效的语法,您需要为其保留回声。 Otherwise, it won't work. 否则,它将无法正常工作。

iframe elements load external documents; iframe元素加载外部文档; the HTML that goes between their start and end tags is alternative content for browsers which do not support iframes . 在它们的开始标记和结束标记之间插入的HTML是不支持 iframe的浏览器的替代内容

If you want a scrolling area on a page, apply the CSS overflow property to an appropriate element (probably a div in this case). 如果要在页面上滚动区域, 则将CSS overflow属性应用于适当的元素(在这种情况下,可能是div )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM