I would like to display the posts of my friends (who accept invitation) just like facebook do in php, mysql.
I have 2 tables : amis (friends) and statuts (posts)
(1) : Table : amis (friends)
id | a (which is "to") | par (which is "by") | statut (which is "status") | time
(2) : Table statuts (posts)
id_statut | membre (email) | contenu (which is "content") | id_pub (which is "id of business page" only for business account) | s_membre_id (which is "id of user") | image | nom_image (name of image) | musique (music file) | video | video_type | lat | lon | time_statut
I would like to select "a" (to) = $_SESSION['membre_id'] AND "par" (by) = $_SESSION['membre_id'] from table amis (friends)
Also, "a" (to) and "par" (by) = s_membre_id (id of user)
// lancement de la requête
$sql = "SELECT * FROM statuts AS s, amis AS a WHERE a.par='".$_SESSION['membre_id']."' AND a.statut='confirme' AND a.par = s.s_membre_id OR a.a='".$_SESSION['membre_id']."' AND a.statut='confirme' AND a.a = s.s_membre_id GROUP BY s.id_statut ORDER BY s.time_statut DESC ";
// on lance la requête (mysql_query) et on impose un message d'erreur si la requête ne se passe pas bien (or die)
$req = mysql_query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
// on va scanner tous les tuples un par un
while ($data = mysql_fetch_array($req)) {