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! Link to comment https://forums.phpfreaks.com/topic/296508-getting-an-array-from-a-table-with-php-and-mysql/ 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 Link to comment https://forums.phpfreaks.com/topic/296508-getting-an-array-from-a-table-with-php-and-mysql/#findComment-1512714 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? Link to comment https://forums.phpfreaks.com/topic/296508-getting-an-array-from-a-table-with-php-and-mysql/#findComment-1512716 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. Link to comment https://forums.phpfreaks.com/topic/296508-getting-an-array-from-a-table-with-php-and-mysql/#findComment-1512745 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.