In my application I'm trying to create an option to be friends. At this moment person X can send a request to person Z and I can put the data in sql. Person X = $_SESSION['name'] and person Z is $buddy['username'] (which I retrieve with my function GetUserById($user_id) )
Now, Person Z has to accept or to decline the request. I want to do it by showing 'Person X wants to be your friend', but I don't know how to pick the name 'Person X'? In first instance he was the $_SESSION['name'] but now person it is person Z.
Can I use a data-attribute on a button without ajax? Or can I do it otherwise?
You can have a database table that stores: requester id, requestee id, status (pending, accepted, declined)
Then, when you want to show requests to Person Z, simply select all requester ids where: requestee id is equal to Person Z and status is pending.
In your case, it would give you Person X's id.
If you don't have ids, you can use usernames instead.