Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在url中包含查询字符串并保持在同一页面上?_Php - Fatal编程技术网

Php 如何在url中包含查询字符串并保持在同一页面上?

Php 如何在url中包含查询字符串并保持在同一页面上?,php,Php,我生成了一个带有锚标签的月份标签,href等于查询字符串?m=1&y=2014。年份部分将使用“下一步”和“上一步”按钮相应递增。顺便说一下,这是在wordpress环境中 --代码-- “下一年”和“上一年”按钮 <div class="table-header"> <div class="table-header-wrapper"> <div class="prev"></div>

我生成了一个带有锚标签的月份标签,href等于查询字符串?m=1&y=2014。年份部分将使用“下一步”和“上一步”按钮相应递增。顺便说一下,这是在wordpress环境中

--代码-- “下一年”和“上一年”按钮

<div class="table-header">
            <div class="table-header-wrapper">
                <div class="prev"></div>
                <div class="year"><?php echo $current_year; ?></div>
                <div class="next"></div>
            </div>
        </div>

--代码-- 制表月份

<?php
                    for ( $monthNum = 1; $monthNum <= 12; $monthNum++ ) :
                        $month = date( 'M', mktime( 0,0,0, $monthNum, 1, $current_year ) ); // month in 3 letter format e.g. Jan
                        $current_monthNum = date( 'n' ); // current month in number
                ?>
                    <div class="<?php echo strtolower( $month ); ?> month" data-month="<?php echo $monthNum; ?>">
                        <a href="<?php echo home_url( 'admin-events-list' ).'/?'.addQuery( array( 'm' => $monthNum, 'y' => $current_year )); ?>" class="<?php echo ( $current_monthNum == $monthNum ? 'current' : '' ); ?>"><?php echo $month; ?></a>
                    </div>
                <?php
                    endfor;
                ?>


使用PHP是不可能的,因为PHP是一种服务器端脚本语言

您可以使用jQuery实现它

插件满足您的需要

在这里,您可以在某些事件上更改url的哈希值

并在
haschange
上触发一些事件


您可以在
Previous
Next
按钮上更改哈希值。

您应该使用JavaScript。谢谢@ROX,这也是我的想法,但即使在单击月份选项卡时页面加载数据,它仍然可行吗?我将加载当前所选月份的数据。这仍然不起作用,因为它仅适用于哈希,而不适用于查询字符串。它假设在单击某个选项卡时附加这些查询字符串。