我Get
在表单中使用方法从页面中获取名称变量,但它只获取名字并将部分留在空格之后。我想选择完整的字段以及空格。
<a href=view_contsheet.php?Patientid=<?php echo $_GET["id"]; ?>&Patientname=<?php echo $_GET["Patientname"];?>>View Visits</a>
在这个链接中,只有名字被传递。如何连接完整的字段?
这可能是因为 URL 中不允许使用空格。
<a href="view_contsheet.php?Patientid=<?php echo $_GET["id"]; ?>&Patientname=<?php echo urlencode($_GET["Patientname"]);?>">View Visits</a>
urlencode()
将使参数 url 友好。还有一个urldecode()
功能,它做的相反urlencode()
试试这个代码
<a href="view_contsheet.php?Patientid=<?php echo $_GET["id"]; ?>&Patientname=<?php echo urlencode($_GET["Patientname"]);?>">View Visits</a>
并在下一页使用urldecode
在我看来,您根本不应该在网址中发送患者的姓名。
代替
<a href=view_contsheet.php?Patientid=<?php echo $_GET["id"];?>&Patientname=<?php echo $_GET["Patientname"];?>>View Visits</a>
做
<a href="view_contsheet.php?Patientid=<?php echo $_GET["id"]; ?>">View Visits</a>
在 view_contsheet.php 中,您根据 Patientid 获取名称
$id = $_GET['Patientid'];
"select Patientname FROM patients WHERE Id=$id"....