I need some help in php. I’m fairly new to the language, though I’m using it on Wamp for a website, which should display a table with an ID and a submit button in each row that when clicked, should display the information for that specific row only. The syntax that I came up with has one problem, it shows the information for all the rows instead of just the one clicked. The code is as follows:
<?php
print "<table>";
Table Headers
print "<tr>";
print "<th>ID</th>";
print "<th>Click to View Row Info</th>";
print "</tr>";
Table Contents (ID & Button in 5 rows)
for ($i=1; $i<=5; $i++){
print "<tr>";
print "<form method=\"post\" action=\"Popup.php\">";
print "<td>";
print "<input name=\"$i\" type=\"text\" value=\"";
echo $i;
print "\"/>";
print "</td>";
print "<td>";
print "<input type=\"submit\" name=\"submit\" value=\"View Row\" /></form>";
print "</td>";
print "</tr>";
}
Popup.php Display Code Snippet
$sub=$i;
for ($i=0; $i<=$sub; $i++){
print "The ID for this row is: ";
echo $i;
}
?>
Popup.php is a separate file that receives the form variables and displays it. If I could get some assistance with this I would be most grateful. If anything is unclear about my question please feel free to let me know.
The form needs to be outside of the loop (and should be outside of the tbale as well)
Also, change the input name so like this
so this
THen in popup.php change it to