There is such a table output from MySql. How to set the delete line when you click the delete link

while($rows = $result->fetch_assoc())[1] { print '<tr> <td>'.$rows ['first_name'].'</td> <td>'.$rows ['last_name'].'</td> <td>'.$rows ['gender'].'</td> <td>'.$rows ['nationality'].'</td> <td>'.$rows ['countries'].'</td> <td>'.$rows ['adress'].'</td> <td>'.$rows ['passport'].'</td> <td>'.$rows ['phone'].'</td> <td>'.$rows ['date_birsd'].'</td> <td><a href="del_sportsmans.php">Π£Π΄Π°Π»ΠΈΡ‚ΡŒ</a></td> </tr>'; } 

[ enter image description here ]

    1 answer 1

    First, you should find out which field in the table is a unique identifier (id).

    Next, update the deletion link by adding this identifier there (substitute the required field instead of 'id'):

     '<td><a href="del_sportsmans.php?id='.$rows['id'].'">Π£Π΄Π°Π»ΠΈΡ‚ΡŒ</a></td>' 

    The del_sportsmans.php file logic:

    Get the id:

     $id = $_REQUEST['id']; 

    Make a removal request:

     DELETE FROM <имя Ρ‚Π°Π±Π»ΠΈΡ†Ρ‹> WHERE <ΠΈΠ΄Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ‚ΠΎΡ€>=$id