pixelz Posted May 27, 2015 Share Posted May 27, 2015 Hey, TL:DR: The goal I want to achieve is getting statuses from a user's friends w/ an array of friends.. Things already set up: Table for statuses - id(an incremental thing to count), osid(what post, to allow comments), author, user_id(the author's id), type[a,b] (a is a post, b is a comment) and postdate. Table for friends - id(incremental), user1(person that initiated the friendship), user1_id(that person's id), user2(person that accepts the friendship), user2_id(his id), datemade What needs to happen is create an array of all a user's friends pseudo code: "Select user2_id where user1_id is logged_in_user_id" "friends[] = loop(mysql query until no more)" "loop:Select statuses where user_id is friends" "Populate my screen with statuses" I know this is bad pseudo code but please help me put together a working system! Quote Link to comment Share on other sites More sharing options...
Barand Posted May 27, 2015 Share Posted May 27, 2015 A single joined query should do it SELECT author , osid , type , postdate FROM friends f INNER JOIN statuses s ON f.user2_id = s.user_id ORDER BY author Quote Link to comment Share on other sites More sharing options...
pixelz Posted May 27, 2015 Author Share Posted May 27, 2015 A single joined query should do it SELECT author , osid , type , postdate FROM friends f INNER JOIN statuses s ON f.user2_id = s.user_id ORDER BY author How would I implement this? Quote Link to comment Share on other sites More sharing options...
ginerjm Posted May 28, 2015 Share Posted May 28, 2015 Probably by writing some php code that includes some db connection and a query and a while loop to handle the query results and some more php to output the data and some html to wrap it all up in a proper web page. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.