HTML表格中的`iframe`
I am displaying some data from a database into my cms, using tables (tr
, td
).
<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
. However, if I take out the iframe
tag, everything works fine, and I can see all the stored values from the database.
<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?
我使用表格( 不幸的是,我的 所以我的主要问题是如何在 tr code>,将数据库中的一些数据显示到我的cms中, TD 代码>)。 p>
&lt; tr align =“center”&gt;
&lt; td&gt;&lt;?php echo $ i ++; ?&gt;&lt; / td&gt;
&lt; td&gt;&lt;?php echo $ post_image; ?&gt;&lt; / td&gt;
&lt; td&gt;&lt;?php echo $ post_title; ?&gt;&lt; / td&gt;
&lt; td&gt;
&lt; iframe width =“100px”frameborder =“0”id ='inneriframe'scrolling = yes&gt;
&lt;?php echo $ post_description; ?&gt;
&lt; / iframe&gt;
&lt; / td&gt;
&lt; td&gt;&lt; a href =“index.php?edit_football_news =&lt;?php echo $ post_id;?&gt;”&gt;编辑&lt; ; / a&gt;&lt; / td&gt;
&lt; td&gt;&lt; a href =“includes / delete_football_news.php?delete_football_news =&lt;?php echo $ post_id;?&gt;”&gt;删除&lt; / a&gt;&lt; / td&gt;
&lt; / tr&gt;
code> pre>
iframe code>中并没有显示描述php变量。 但是,如果我取出
iframe code>标记,一切正常,我可以看到数据库中存储的所有值。 p>
&lt; tr align =“center”&gt;
&lt; td&gt;&lt;?php echo $ i ++; ?&gt;&lt; / td&gt;
&lt; td&gt;&lt;?php echo $ post_image; ?&gt;&lt; / td&gt;
&lt; td&gt;&lt;?php echo $ post_title; ?&gt;&lt; / td&gt;
&lt; td&gt;&lt;?php echo $ post_description; ?&gt;&lt; / td&gt;
&lt; td&gt;&lt; a href =“index.php?edit_football_news =&lt;?php echo $ post_id;?&gt;”&gt;编辑&lt; / a&gt;&lt; / td&gt;
&lt; td&gt;&lt; a href =“includes / delete_football_news.php?delete_football_news =&lt;?php echo $ post_id;?&gt;”&gt;删除&lt; / a&gt;&lt; / td&gt;
&lt; / tr&gt;
code> pre>
td code> s中使用iframe? p>
div>
iframe
elements load external documents; the HTML that goes between their start and end tags is alternative content for browsers which do not support iframes.
If you want a scrolling area on a page, apply the CSS overflow
property to an appropriate element (probably a div
in this case).
As I mentioned in comments (but gotten no response from).
iframe requires a source
src="file.xxx"
.https://developer.mozilla.org/en/docs/Web/HTML/Element/iframe
Taken from example #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; ?>
from the iframe and just do:
<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.
That's how you'll get your iframe to show the contents "on screen" rather than in HTML source.
If you had a look at your HTML source as I also mentioned in comments, you would indeed have seen the contents.
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.
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.