php 如何创建一个带框架的php页面?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6836853/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create a php page with frames?
提问by roymustang86
<html><head></head>
<frameset cols="30%,*">
<frame src="menu.php">
</frameset>
</html>
This is my index.php page. And the menu.php page lists a set of clients from mysql.
这是我的 index.php 页面。menu.php 页面列出了一组来自 mysql 的客户端。
I want to create a hyperlink with the result of the mysql query. And when you click on the mysql, it should call content.php and display the contents in the second frame.
我想用 mysql 查询的结果创建一个超链接。当您单击 mysql 时,它应该调用 content.php 并在第二帧中显示内容。
But so far, on clicking the hyperlink, it redirects the menu frame to the other php page.
但到目前为止,在单击超链接时,它会将菜单框架重定向到另一个 php 页面。
Basically, I am trying to create a menu on the left hand frame and display contents of each listing on the right frame.
基本上,我试图在左侧框架上创建一个菜单,并在右侧框架上显示每个列表的内容。
回答by Marc B
Don't use frames. They're a hideous throwback to the "old" days. It's easy to replicate the few benefits frames provided with PHP includes (dynamic/constant sidebars/menus/content shared across multiple pages), without ANY of the long list of drawbacks that frames have.
不要使用框架。它们是对“旧”时代的可怕回归。很容易复制 PHP 提供的框架所包含的一些好处(动态/恒定侧边栏/菜单/跨多个页面共享的内容),而没有框架具有的任何一长串缺点。
回答by duskwuff -inactive-
Frames are a huge mess. However, if you must, you can give your frames name
s, then specify a target
attribute on the links in the menu frame to say which frame it should open in.
框架是一个巨大的混乱。但是,如果必须的话,你可以给你的框架name
s,然后target
在菜单框架中的链接上指定一个属性来说明它应该在哪个框架中打开。
Also, don't use frames.
另外,不要使用框架。
回答by shaggy
It has nothing to do with php - it is simple html.
You have to use targetatribute in your <a>
links.
Your code will be something like:
它与 php 无关——它是简单的 html。
您必须在链接中使用目标属性<a>
。
您的代码将类似于:
<frameset cols="30%, 70%">
<frame src="menu.php">
<frame src="content.php" name="content">
</frameset>
link in your menu.php will be:
menu.php 中的链接将是:
<a href="content.php?page=somepage" target="content">Somepage</a>