不知道从哪里开始在php中选择一行

Ok guys I know this might not be the correct way to ask a question but I have looked as far as I could go. I am a bit stuck on how to go about this problem, probably why I can't find a solution to it. I have a form that the info gets inserted to a db, then you are able to view the info from the database on another page that list everything inserted. My question is how would I go about selecting a row from the table that displays all the info from a row on the db and redirect to another page to edit it? I want to redirect to another page to view/edit all the info.

What I think would work is in the table that shows the info I could put a radio box and have a button at the top to click to edit that row. I don't really know how to assign that radio button to the actual row however.

Here is my table:

<?php
                $sql = "SELECT * FROM employees ORDER BY LastName";
                $result = $mysqli -> query($sql);

                if ($result->num_rows > 0) {
                    echo "
                    <table class='table table-hover table-responsive'>
                        <thead class='thead-dark'>
                            <tr>
                                <th class='table-primary' scope='col'>#</th>
                                <th class='table-primary' scope='col'>First Name</th>
                                <th class='table-primary' scope='col-1'>M.I.</th>
                                <th class='table-primary' scope='col'>Last Name</th>
                                <th class='table-primary' scope='col'>Phone</th>
                                <th class='table-primary' scope='col'>Address</th>
                                <th class='table-primary' scope='col'>Email</th>
                                <th class='table-primary' scope='col'>Birth Date</th>
                                <th class='table-primary' scope='col'>EID</th>
                                <th class='table-primary' scope='col'>Gender</th>
                                <th class='table-primary' scope='col'>Ethnicity</th>
                                <th class='table-primary' scope='col'>Status</th>
                                <th class='table-primary' scope='col'>Hours</th>
                                <th class='table-primary' scope='col'>EAP Access</th>
                            </tr>
                          </thead>";
                    // output data of each row
                    while ($row = $result->fetch_assoc()) {
                        echo "
                        <tbody>
                            <tr class='table-dark'>
                                <td>" . $row['UserID']. "</td>
                              <td>" . $row['FirstName']. "</td>
                              <td>" . $row['Middle']. "</td>
                              <td>" . $row['LastName']. "</td>
                                <td>" . $row['PrimaryPhone']. "</td>
                                <td>" . $row['Address'] . $row['City'] . $row['State'] . $row['Zipcode']. "</td>
                                <td>" . $row['Email']. "</td>
                                <td>" . $row['DateOfBirth']. "</td>
                                <td>" . $row['EID']. "</td>
                                <td>" . $row['Gender']. "</td>
                                <td>" . $row['Ethnicity']." </td>
                                <td>" . $row['Status']. "</td>
                                <td>" . $row['Hours']. "</td>
                                <td>" . $row['eapAccess']. "</td>
                            </tr>
                        </tbody>";
                    }
                    echo "</table>";
                } else {
                    echo "0 results";
                }
            ?>

If I added a <input type="radio" name="selected"> before the userID column like and had a button to select that row, how would I be able to have that row display on a seperate page?

I am still new to php, but this is beyond me and can't find anything remotely close to an answer.

Few steps to be done:

  1. add the input radio before before the user ID
  2. wrap whole table with the <form> elements with defined method and action attributes
  3. add the submit button inside the form to send the values
  4. on next script you will receive the value within $_GET or $_POST
  5. process all what you need with received user ID

Study more about (search internet for more info):

  • HTML forms
  • PHP Form Handling
  • PHP GET and POST Method Tutorials

Your as well as all other information you what to send to another script should be wrapped inside . Set the form action, i.e the script path, and use either POST or GET method( I prefer POST). On your next script, you will probably use isset() to check if the userID was received, then you can Carry on from there.