mac香港专柜价格:两个.php网页之间有没有办法传值?(在线等,有补充,有加分)

来源:百度文库 编辑:高考问答 时间:2024/04/30 14:43:22
比如在一个框架网页中左框架的.php网页上有两个链接A和B
点击A则右框架从数据库中调用并显示A的资料
点击B则右框架从数据库中调用并显示B的资料
右框架只做一个.php网页来实现这些,可能吗?

我是初学者
最好给一段这种的示例代码
谢谢!

可以在AB连接后面加上变量,然后右边的接受下来就知道要显示哪个了
比如
a.php?action=A
b.php?action=b
右边的页面这样接收
$action=$_GET['action']
然后判断$action的值
输出相应内容

简单!
写了最简单的,你看一个意思!
其实就是将链接的target指向该框架.
main.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<frameset cols="80,*" frameborder="no" border="0" framespacing="0">
<frame src="left.html" name="leftFrame" scrolling="No" noresize="noresize" id="leftFrame" title="leftFrame" />
<frame src="right.php" name="mainFrame" id="mainFrame" title="mainFrame" />
</frameset>
<noframes><body>
</body>
</noframes></html>

left.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<p><a href="right.php?p=show" target="mainFrame">显示</a></p>
<p><a href="right.php?p=me" target="mainFrame">我</a></p>
</body>
</html>

right.php

<?php
echo $_GET['p'];
?>