I have this PHP code that lets me know if I have registered friends (when I enter their profile, there is the button that says ADD), if the user is my friend it says AGGREGATED.very good. But I would like you to help me When I press the button (which is a link), this will execute some code to insert the ID of this user in the BD (If it is not my friend). Whether through ajax, I do not know. But of course when I click.
I would like it to be within the ELSE.
<?php
include_once('conexion.php');
if ($user != $my_id) {
$mysqli = mysqli_connect("localhost", "root", "", "registros");
$quer = mysqli_query($mysqli,"SELECT * FROM friends WHERE (User_one =
'$my_id'
AND User_two = '$user') OR (User_two = '$user' AND User_one = '$my_id')");
if (mysqli_num_rows($quer) == 1)
{
$mensaje = "<a href= '#'>Already Friends</a>";
}
else{
$mensaje = "<a href= 'agregarN.php?Id=".$user."'>No Friends</a>";
}
}
?>