.
.
.
while ( $row = mysql_fetch_array($res) )
{
echo "<tr>";
echo "<td><input type=\"radio\" name=\"mod\" /></td>";
echo "<td>" . $row['a'] . "</td>";
echo "<td>" . $row['b'] . "</td>";
echo "<td>" . $row['c'] . "</td>";
echo "<td>" . $row['d'] . "</td>";
echo "<td>" . $row['e'] . "</td>";
echo "</tr>";
}
echo "</table>
Printing database data to an HTML table with PHP “echo”.
For example, when this displays, there will be X rows of 6 columns (5 data and one a radio button).
For the row selected with the radio button, I need all of that specific rows data to POST to another .php page.
My initial thought was create an onClick() function for the radio button, with the data as parameters to the functions, then, having the function do an AJAX POST with that data.
or should I create a form around the table? If so, how would I get that rows data as form data?
Is there a better way?
If you have some ID for each row you should simply associate it with the radio button and once submitted your PHP script will be able to determine which was selected based on the sent id.
Also generally I would suggest not to print HTML from PHP but embed it as it is supposed to be done