Creating a FRIEND RELATION in MySQL and PHP -


i creating system keep relationships in application. when says stored in database id, , friend (in order). , when other person accepts request id of friend , other id (in reverse order) saved.

to verify 2 friends have see there these 2 rows.

the last problem when true, have retrieve name of friend table .. , not know how express in php.

i've been testing, , should this. here code:

select nombre users  join friends (id=usuari_o or id=usuari_t) ,  (usuari_t='$id' or usuari_o='$id') 

friends tables structure:

enter image description here

users table structure:

enter image description here

something this:

select original.nombre original_nombre, friends.usuari_o, target.nombre target_nobmre, friends.usuari_t friends left join users original on original.id = friends.usuari_od left join users target on target.id = friends.usuari_t; 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -