Jump to content

Help with join query


acegames

Recommended Posts

Can anyone help me with this code please

 

I need to add this query to the code so it gets results where friendid and requesterid both are approved ="1"

 

$psql = mysql_query("SELECT * FROM `friends` WHERE `friendid`='$id' AND `approved`='1'", $conn);

 


$psql = mysql_query("SELECT * FROM `friends` WHERE `requesterid`='$id' AND `approved`='1'", $conn);

$num = mysql_num_rows($psql);





       $psql = mysql_query("SELECT * FROM `friends` WHERE `requesterid`='$id' AND `approved`='1' LIMIT $start , 5;", $conn);	

$left = mysql_num_rows($psql);

?>

<?





if($num>0) {

while($prow = mysql_fetch_array($psql)) {

		$r = $prow["friendid"];



		$n="navItem1";

		$x=$x+1;

		if($x%2==0) {

			$n="navItem2";

		}



		$sql1 = mysql_query("SELECT * FROM `members` WHERE `id`='$r'", $conn);

		while($row1 = mysql_fetch_array($sql1)) {

			$av = $row1["avatar"];

		}





		if($av) {

			$av = "<a href=\"profile.php?id=$r\"><img src=\"$av\" class=\"img\" /></a>";

		} 

		else {

			$av = "<a href=\"profile.php?id=$r\"><img src=\"default.gif\" class=\"img\" /></a>";

		}

Link to comment
https://forums.phpfreaks.com/topic/165071-help-with-join-query/
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.