Jump to content

[SOLVED] query problem


timmah1

Recommended Posts

I'm not sure the correct way to do this or to word this.

I need to be able to select everything posted from myself and from people that I'm subscribed to.

 

I tried JOINS, but I do not get the results I need, so I remember someone before showing me a different way, but all I keep getting are results for me, not from who i subscribe to as well.

 

Here is my code

<?php
$query2 = "SELECT * FROM users1 WHERE userid = '$user'";
                    $result2 = mysql_query($query2);
                    $p2 = mysql_fetch_assoc($result2);
					$follower = $p2['followers'];
					$me = $p2['userid'];

		//Grab all posts from user, and from their subscribers
		$query = "SELECT * FROM posts WHERE userid = '$follower'";
		$query = "SELECT * FROM posts WHERE userid = '$me' ORDER BY posted DESC";
                    $result = mysql_query($query);
                    while($p = mysql_fetch_assoc($result)){

					$posted = date("F j, Y g:i a", strtotime($p['posted']));
					$going = $p['going'];
					$city = $p['city'];
					$state = $p['state'];
					$p_user = $p['userid'];
					$p_folow = $p['followers'];
?>

 

Basically, I need to grab all posts from $me and from $follower.

 

Can anybody show me the correct way?

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/151997-solved-query-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.