1

所以我在 sampleform.html 有一个表单,它接受用户的值 [这是从下拉菜单中选择的数字。数字是病房id]

这个数字通过 GET 方法传递给 index.php。现在,在 index.php 上,用户可以看到与他选择的数字相关的详细信息(来自 mysql 数据库),并且他有两个链接可供选择:

  1. 货车路线
  2. 三轮车路线

我想通过超链接 url 传递一个新变量 'route=lor' 或 'route=tri' 以及来自 sampleform.html 的原始病房号到一个新页面 - route.php 通过 index.php

我在 index.php 上尝试了 $_SESSION,其中 $_SESSION['wardno'] 接受来自 sampleform.html 的 $_GET['wno'] 值。但是当我调用 $_SESSION['wardno'] 时,我无法在 route.php 上看到任何输出。

单击 index.php 上的两个超链接之一后,如何从 sampleform.html、index.php 和 route.php 传递这个变量?

我没有看到语法错误。如果你们不明白这个问题,将提出代码。

帮助表示赞赏。提前致谢,

考希克

4

1 回答 1

0

href在两个超链接的属性中包含要通过 index.php 传递的任何 GET 查询变量的名称和值。


代码片段#1

<?php
    function getparams() {
        foreach ($_GET as $k => $v)
            $r .= htmlspecialchars(urlencode($k)) . '=' .
                  htmlspecialchars(urlencode($v)) . '&';
        return $r;
    }
?>
<a href="route.php?route=lor&<?php echo getparams(); ?>">link 1</a>
<a href="route.php?route=tri&<?php echo getparams(); ?>">link 2</a>
于 2012-04-13T10:48:23.213 回答