Wignu
Wignu

Reputation: 77

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. The html link is as follows:

<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, i.e. 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.

The query runs as it should as I get correct results when using it in other areas on the html page. Not sure if it makes a difference but have 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.

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.

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.

Upvotes: 0

Views: 776

Answers (2)

Andrea Fiore
Andrea Fiore

Reputation: 116

You are using the # in front of your url so the $_GET can't catch it. Try to remove it or parse the entire url looking for your parameter.

Upvotes: 1

m1xolyd1an
m1xolyd1an

Reputation: 535

Did you try storing as session variable?

session_start();
$_SESSION['pmntid']= $row[0];

Then on the popup page do

session_start();
$pmntid = $_SESSION['pmntid'];

Upvotes: 0

Related Questions