Im trying to pass two values to a second page One of the values is a name (eg John Doe) and have spaces when i $_Request in on the other page and echo it only John shows
Heres from the 1st page
<td> "."<a rel=facebox href=add.php?id=".$id."&acname=".$row['name'].">".$row['name']."</a>". "
Second Page
$id=$_REQUEST['id'];
$acname=$_REQUEST['acname'];
Trying to echo it here
<td><input type="text" name="c_id" id="c_id" value="<?php echo $id; ?>"
<td><input type="text" name="fname" id="fname" value="<?php echo $acname; ?>"
Can this be done? OR should i try a different approach
答案 0 :(得分:0)
有人在评论中用几秒钟打败了我,但我还是会回答,因为我还有一个链接:
http://php.net/manual/en/function.urlencode.php
urlencode
将空格更改为+
或%20
,并映射其他字符以确保它们适合在网址中使用。
答案 1 :(得分:0)
在将值发送到第二页之前,您必须对其进行urlencode:
<td> "."<a rel=facebox href=add.php?id=".$id."&acname=".urlencode($row['name']).">".$row['name']."</a>". "
答案 2 :(得分:0)
您需要urlencode() $row['name']
:
// here:
echo "<td> "."<a rel=facebox href=add.php?id=".$id."&acname=".urlencode($row['name']).">".$row['name']."</a>";
然后,空格将被编码为%20
并正确传递。