Glenskie Posted February 13, 2012 Share Posted February 13, 2012 ok , here is my mysql code to get all posts from the posts table . $query = mysql_query("SELECT id,to_id,from_id,post,type,state,date FROM posts WHERE state='0' ORDER BY id DESC LIMIT 50"); and here is the code to display the users friends... $sqlArray = mysql_query("SELECT friend_array FROM myMembers WHERE id='" . $logOptions_id ."' LIMIT 1"); while($row=mysql_fetch_array($sqlArray)) { $iFriend_array = $row["friend_array"]; } $iFriend_array = explode(",", $iFriend_array); if (in_array($id, $iFriend_array)) see now i got as far as , if(in_array($id, $iFriend_array)) How would i put these togeather to where it would get the posts from the posts table that there friends posted? Link to comment https://forums.phpfreaks.com/topic/256993-how-to-get-things-from-two-databases-with-php/ Share on other sites More sharing options...
scootstah Posted February 13, 2012 Share Posted February 13, 2012 With JOINs. Something like... SELECT p.id, p.to_id, p.from_id, p.post, p.type, p.state, p.date, m.friend_array FROM myMembers AS m LEFT JOIN posts AS p ON p.to_id = m.id WHERE p.state = '0' AND m.id = '" . $logOptions_id . "' Link to comment https://forums.phpfreaks.com/topic/256993-how-to-get-things-from-two-databases-with-php/#findComment-1317431 Share on other sites More sharing options...
Glenskie Posted February 13, 2012 Author Share Posted February 13, 2012 ok , thank you it works , but for some reason it gets only the posts that were To that user , not all the posts from all of there friends even if they wernt to them Link to comment https://forums.phpfreaks.com/topic/256993-how-to-get-things-from-two-databases-with-php/#findComment-1317833 Share on other sites More sharing options...
Glenskie Posted February 17, 2012 Author Share Posted February 17, 2012 its not working Link to comment https://forums.phpfreaks.com/topic/256993-how-to-get-things-from-two-databases-with-php/#findComment-1318392 Share on other sites More sharing options...
Glenskie Posted February 17, 2012 Author Share Posted February 17, 2012 its not showing the friends posts , i want it to show there posts , even if the post wasent to the user , just there post in general Link to comment https://forums.phpfreaks.com/topic/256993-how-to-get-things-from-two-databases-with-php/#findComment-1318393 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.