在PHP中编辑表行,但它正在获取表的最后一行的详细信息

enter image description hereI want to edit the contents of the row in the database. For that I have made a table from database with edit and delete button. Delete button is working fine with ajax. While clicking the edit button and moving to next page it is showing details of the last row in the table. I want to get details of current row that i have clicked the edit button.

My PHP code is

<form method="post" action="edit_team.php"> 
<?php
error_reporting(0);
//session_start();
include 'database-config.php';

$selectquery = "SELECT * FROM `register_team`" ;

$group_result = mysql_query($selectquery, $conn);

$a=0;

while ($container_id_record = mysql_fetch_assoc($group_result)) {
$a++;

echo "<tr class='gradeA odd' role='row'><td class='sorting_1'>" . $a . "</td><td>" . $container_id_record['team_name'] . "</td><td>" .$container_id_record['team_coach']. "</td><td>" . $container_id_record['team_manager'] .  "</td><td>" . $container_id_record['team_contact'] .  "</td><td>". $container_id_record['team_email']. "</td><td><button type='submit'><i class='fa fa-edit edit' title='". $container_id_record['team_name_coach']. "'></i></button></td><td><i class='fa fa-trash delete' title='". $container_id_record['team_name_coach']. "'></i></td></tr>";
  $team = $container_id_record['team_name_coach'];
}

?>
<input type="hidden" name="team_name_coach" id="team_name_coach" value="<?php echo $team;?>"/>

My edit_team.php is

$team_name_coach = $_POST['team_name_coach'];

While doing from ajax it is not showing the current value on the next page.

try this one..

  <form method="post" action="edit_team.php"> 
    <?php
    error_reporting(0);
    //session_start();
    include 'database-config.php';

    $selectquery = "SELECT * FROM `register_team`" ;

    $group_result = mysql_query($selectquery, $conn);

    $a=0;

    while ($container_id_record = mysql_fetch_assoc($group_result)) {


    echo "<tr class='gradeA odd' role='row'><td class='sorting_1'>" . $a . "</td><td>" . $container_id_record['team_name'] . "</td><td>" .$container_id_record['team_coach']. "</td><td>" . $container_id_record['team_manager'] .  "</td><td>" . $container_id_record['team_contact'] .  "</td><td>". $container_id_record['team_email']. "</td><td>
<a href = 'edit-team.php/'.$container_id_record['team_name_coach']><i class='fa fa-edit edit' ></i></a></td>
<td><i class='fa fa-trash delete' title='". $container_id_record['team_name_coach']. "'></i></td></tr>";




    }

    ?>

use $_GET instead of $_POST in edit-team.php page.. $team_name_coach = $_GET['team_name_coach'];