2014-09-19 71 views
-1

我有一个问题,我该如何重新编码GET变量..这是非常复杂的解释,但我认为更好地显示代码。重新排序GET变量

http://URL.com/?product_id=23&year=2013&seite=reporting&action=jahres&report=jahres 

但我真的很想这样。

http://URL.com/?seite=reporting&action=jahres&report=jahres&product_id=23&year=2013 



<input type="hidden" name="seite" value="reporting"/> 
<input type="hidden" name="action" value="jahres"/> 
<input type="hidden" name="report" value="jahres"/> 

表单的动作只是页面的URL。

GET变量?seite = reporting,< ---我需要始终站在所有其他变量的前端,我该怎么办?

感谢您的帮助!

+3

是否为了真正的问题呼应他们一个接一个? (仅供参考,答案是否定的) – 2014-09-19 13:00:59

+1

更多用于stetic你知道,我只是想知道是否有可能做到这一点 – 2014-09-19 13:01:53

回答

0

如果您隐藏的输入您可以订购您的网址这些变量的角度看,reording这些变量的位置,例如:

<input type="hidden" name="seite" value="reporting"/> 
<input type="hidden" name="action" value="jahres"/> 
<input type="hidden" name="report" value="jahres"/> 

你可以这样做:

<form> 
1. First Level in your form 
<input type="hidden" name="seite" value="reporting"/> 

2. Last level in your form the other variables hidden or not. 
    <input type="hidden" name="action" value="jahres"/> 
    <input type="hidden" name="report" value="jahres"/> 
</form> 

如果您要访问的变量:

$seite = isset($_GET['seite']) ? $_GET['seite'] : null; 

当你按下提交按钮时,表单会隐藏第一个输入,GET在你的URL中,但实际上并不重要,只是为了stetic!

+1

谢谢!有用! – 2014-09-19 13:09:50

1

如果您自己将它们传递给url,那么放置它们的顺序无关紧要。

没关系。您可以添加更多的查询字符串参数,或者以任意顺序删除它们。然后使用$_GET["product_id"]等访问它们并进行相应处理。

1

GET变量没有排序,您可以按照您想要的顺序放置它们,它仍然会给出相同的结果。

0

你可以把你的GET变量数组中的

$variables = Array (
[0] => $_GET['one'] 
[1] => $_GET['two'] 
[2] => $_GET['three'] 
); 

然后只需在URL输出

$url = "http://website.com/script.php?get1=" . $variables[0] . "&get2=" . $variables[1];