button function for all fetch row : now i m doing project for my university. i have a problem,i create  page where user can send friend request.here i fetch data from another table and put button for each row data. my problem is  when one button click other row button also was change to friend request. i need a solution for it. how to make one add friend request button is equal to one row id and how to avoid other button affected whenever click particular row.Below i attach my code. I hope you guys will help me. thanks in advance.
php

    <?php
    session_start();
    $_SESSION['myid'];
    
    $mysqli=new MySQLi('127.0.0.1','root','','learning_malaysia');
    $sql = "SELECT * FROM tutor_register INNER JOIN tutorskill ON tutor_register.register_ID = tutorskill.register_ID ORDER BY 
    tutor_register.register_ID='".$_SESSION['myid']."'desc";
    $result= mysqli_query($mysqli,$sql);
    
    if(mysqli_num_rows($result)>0)
    {
    	 
    	while($row = mysqli_fetch_array($result))
    {      
       
    
             $register_ID=$row["register_ID"];
        		$username = $row['username'];
        		$profile = $row['profile'];
        		$email = $row['email'];
        		$address=$row['address'];
        		$gender=$row['gender'];
        		 $main_subject=$row["main_subject"];
        		 $subject_add=$row["subject_add"];
        		$rate_main=$row["rate_main"];
        		$rate_add=$row["rate_add"];
        		$qualification=$row["qualification"];
        		?>
                <table><form method="post">
                <tr class="border_bottom">
                <td height="230"><img src='<?php echo $profile;?>'width="200" height="200"/>&nbsp;</td><td><td></td></td>
     <?php 
    		 if($register_ID == $_SESSION['myid']){
    				?>
                    <td><label>Your Profile</label></td>
                    <?php
    			} else {
    				?> 
                     <form method="post">
                     <td><button class='friendBtn unfriend'  name="" data-type="unfriend">Unfriend</button>
                     <input type="hidden" name="id"  value="<?php echo $row['register_ID'];?>" />  
                     <input type="submit" name="addfriend" data-type='addfriend' id="addfriend" value="<?php 
    					 if($_SESSION['status'] == 'yes'){ 
    					 echo 'Request Sent';
    					 }
    					 else { 
    					 echo 'Addfriend';}
    					 ?>" data-uid=<?php echo $row['register_ID'];?>/></td> </form>     
    <?php
    			}
    }
    ?>
     </tr>
    </div>
    </table>
    </form>
    <?php
    if(isset($_POST['id']) ) {
    $user_id = $_SESSION['myid'];
    $friend_id = $_POST['id'];
    $sql="INSERT INTO friends(user_id,status,friend_id)" ."VALUES('$user_id','yes','$friend_id') ";
                    
    			if($mysqli->query($sql)=== true) {
    						  $_SESSION['status']="yes";
    						  $_SESSION['id']=$row['id'];
    			} else {}
    	                          }
    				}
    
    
    ?> 
    </body>
    </html>

