[英]PHP Pass Variable To Popup Page via Href Link From SQL Query
As the title says I'm trying to pass a variable as pmntid from to a DIV, on the same page, for a popup page via href. 如标题所示,我正在尝试通过href将变量pmntid作为变量传递到同一页面上的DIV。 The html link is as follows:
html链接如下:
<td class="listingTextLeft">
<a href="#?pmntid=<?php echo $row[0]; ?>"onclick="document.getElementById('pmntDetailPopup').style.display='block';document.getElementById('pmntDetailFade').style.display='block'"
class="green">
<?php echo $row[20] ?>
</a>
</td>
Hovering over the link shows the correct structure for the variable, ie pmntid=5 and when the link is clicked it brings up the popup in the DIV pmntDetailPopup
, however when using $_GET['pmntid']
there is no value. 将鼠标悬停在链接上会显示变量的正确结构,即pmntid = 5,单击链接后,它将在DIV
pmntDetailPopup
弹出弹出pmntDetailPopup
,但是,使用$_GET['pmntid']
时没有任何值。
The query runs as it should as I get correct results when using it in other areas on the html page. 当我在html页面的其他区域中使用该查询时,该查询将按我应该获得的正确结果运行。 Not sure if it makes a difference but have
session_start();
不知道是否
session_start();
但具有session_start();
at the top of the page. 在页面顶部。
Have searched through Stackoverflow and other sites for an answer but just cannot spot what I am doing wrong and other suggested solutions I've tried do not work. 在Stackoverflow和其他站点中搜索了答案,但无法发现我在做什么错,而我尝试过的其他建议解决方案均无效。
As suggested I've remove the #, however it still did not pass the pmntid to the popup and the popup window only stays open for a matter of seconds. 如建议的那样,我删除了#,但是它仍然没有将pmntid传递给弹出窗口,并且弹出窗口仅保持打开状态约几秒钟。
Should add that I've tried redirecting it to a new php page and it shows the correct pmntid so it is picking up the variable okay, just not passing it to my div. 应该补充一点,我尝试将其重定向到新的php页面,并且显示了正确的pmntid,因此它选择的变量还可以,只是没有将其传递给我的div。
You are using the # in front of your url so the $_GET can't catch it. 您在网址前面使用#,因此$ _GET无法捕获它。 Try to remove it or parse the entire url looking for your parameter.
尝试将其删除或解析整个URL,以查找您的参数。
Did you try storing as session variable? 您是否尝试将其存储为会话变量?
session_start();
$_SESSION['pmntid']= $row[0];
Then on the popup page do 然后在弹出页面上
session_start();
$pmntid = $_SESSION['pmntid'];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.