I have PHP loop ( WHILE{} ) that loops an array from MySQL and creates a page with the data line by line. I need to add to each line a button that will trigger a new page but I need to carry the value of the id of the line to that new pop-up page. This is the code I have, but i can't figure out how to pass my id to the pop up:
I know I can't add my PHP variable to the URL in the JS function, because it sits outside the loop. Can I use the JS function to add it ? Here is some simplified code:
PHP Code
<?php
while ($all = mysql_fetch_array($get_all)){
$id= $all['id'];
echo '<button type='button' class='btn btn-danger' onclick='openWin()'> Click here</button> ';
}
?>
Javascript
<script>
var myWindow;
function openWin() {
myWindow = window.open("http://www.website.com/pop.php", "myWindow", "width=600,height=800");
}
function closeWin() {
myWindow.close();
}
</script>
I need to get $id to the new page. As stated I was hoping to add it to the URL as a $_GET variable, but I don't seem to know how to add it since the url sits in the JS function outside the while loop.
Sorry for the poor indenting
echoare invalid