I created a form and have gone through a similar question on Stackoverflow as well, relating to this area of sending a variable from one page to another.
I need to pass this value $id=$row['id']; to the next page, but if I store it in the session variable (inside the while lopp) then it stored only the last item and not the current value.
<form name="send" method="POST" action="got.php">
<hidden id="value" name="value"/>
//<input type="text" id="value">
//<input type="hidden" name="myVariable" value="'. htmlentities("myVariable").'">;
<input type=submit name=submit value="submit" onclick="<?php session_start(); $_SESSION(this.id) ?>">
</form>
The full code is given below,
echo "<form name=payment action='properties_details.php'>";
echo "Results <br>";
while ($row= mysql_fetch_array($result)) {
echo " <table border=3 cell padding=1> <tr> <td> ";
$id=$row['id'];
$pid=$row['pref'];
//And the remaining values as well
//<input type="hidden" name="myVariable" value="'. htmlentities($pid).'">;
//<input type="hidden" name="myVariable" value="'. $pid.'">;
echo "<p>Property ID  ".$pid;
echo "<br> <p> Name  ";
echo $row["name"];
echo "<br> Properties  ";
echo $row["catergory"];
// And printing the remaining values
echo "<input type=submit name=btnbuy value=Details> ";
<input type=submit name=submit value="submit" onclick="<?php session_start(); $_SESSION(this.id) ?>">You seem to mix JS with PHP.