如何在PHP的href链接中发送多个值? [英] How to send multiple values in a href link in PHP?
本文介绍了如何在PHP的href链接中发送多个值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用href
链接将多个值发送到不同的页面.但是我检索的只是前2个值,其余显示未定义索引的错误.
I want to send multiple values to a different page using a href
link. But what I retrieve is the first 2 values only, rest shows an error of undefined index.
我的代码是:
<?php
echo "<a href='index.php?choice=search&cat=".$cat."&subcat=".$subcat."&srch=".$srch."&page=".$next."'> Next </a>";
?>
我仅获得"choice"和"cat"的值. 请告诉我上面的代码有什么问题.
I get the values of "choice" and "cat" only. Please tell me whats wrong in the above code.
推荐答案
尝试使用urlencode,好像字符串中有任何特殊字符一样,它可能会对整个查询字符串产生影响;
try using urlencode, as if there are any special characters in the strings, it could have an effect on the querystring as a whole;
echo "<a href='index.php?choice=search&cat=".urlencode($cat)."&subcat=".urlencode($subcat)."&srch=".urlencode($srch)."&page=".urlencode($next)."'> Next </a>";
另外,在srch和page之间留有一个空格,这可能是造成问题的原因.
Plus you had a space between srch and page, that could have been causing a problem.
这篇关于如何在PHP的href链接中发送多个值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文