In the table shown in the image,I want to show those names that the user added by clicking save, but if both are added by each other,like if Alice adds Bob and Bob has Added Alice you must indicate it (with some symbol, another color). How to make a database table for this because I'm unable to verify that if User Alice added Bob How do I confirm that Bob has also added Alice to show them in the table below. this is the image what I want to get
here is my code to do this index.php
<form action="save.php" method="post">
<div class="text-center" id='input_tag'>
<input type="text" name="name" id= 'input'>
<input type="submit" name="submit" class="btn btn-dark " id = "button" value="Save">
</div>
</form>
<div class="container">
<div class="row">
<div class="col-md-4">
<table width="100" class="table" id = 'tb'>
<?php
$connect = mysqli_connect('localhost','root','root','user');
$query = "SELECT name from userdata order by id DESC";
$run = mysqli_query($connect,$query);
while($row = mysqli_fetch_array($run))
{
echo "<tr>";
echo "<td class= 'active'>".$row['name']."<td>";
echo "</tr>";
}
?>
</table>
</div>
</div>
</div>
here is save.php
$connect = mysqli_connect('localhost', 'root' ,'root' ,'user');
if($connect){
if(isset($_POST['submit']))
{
$name = $_POST['name'];
$query = "INSERT INTO `userdata`(`name`) values ('$name')";
if(mysqli_query($connect,$query)){
header('location:index.php');
}
}
}
else{
echo "not connected";
}
this is my table in the database table in the DB