dtcwehta624485 2014-03-03 11:35
浏览 179
已采纳

如何将变量从一个页面传递到另一个页面?

I am creating a website, that has many pages. You can change the number of posts shown in each page through a drop down menu. My problem starts if i change the amount of posts move to the next page it comes back to default.

e.x default posts shown is 30, and then i change it to 40. The moment i change page it comes down to 30 again on the next page.

I have tried something like that but unfortunately doesn't work.

<form method="get" name="SkipPage">
<select name="results_no" onChange="document.forms['SkipPage'].submit()"> `
<?php
....
?>
</select>
</form>

$reults_no = isset($_GET['results_no']) ? $_GET['results_no'] : 30;

  • 写回答

2条回答 默认 最新

  • duangouyan3328 2014-03-03 11:38
    关注

    try to use hidden intput

    <input type="hidden" name="myHiddenVar" value="<?php echo $myVar ?>"
    

    Then you can use your var with $_POST["myHiddenVar"];

    But if you want a persistent choice use sessions. session_start(); on each page and access/edit your var with $_SESSION['myVar'];

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元
  • ¥15 matlab答疑 关于海上风电的爬坡事件检测
  • ¥88 python部署量化回测异常问题
  • ¥30 酬劳2w元求合作写文章
  • ¥15 在现有系统基础上增加功能