Screwy code logic for social network
===

Node1id is the user that sent the request and node2id is the user that is receiving the request. How would I limit the code below to only display the request to node2id. I tried doing:

    $row->relationType == 'requested' && node2id == $userid

but it doesn't seem to want to work. Any ideas?

![enter image description here][1]

    <?php
    $selectedId = $_REQUEST['id'];
    $myuserid = $this->session->userdata('userid');
    $query1 = $this->db->query("SELECT * FROM friends WHERE node1id = '{$myuserid}' AND node2id = '${selectedId}'");
    	  foreach($query1->result() as $row) {
    	  if ($row->relationType == 'requested') { ?>
    			<script type="text/javascript">
    				$(document).ready(function() {
    					$("#addFriend").replaceWith('<span id="requestAlert"><span class="font1">wants to be your friend&nbsp;</span><input type="submit" id="acceptRequest" value="Accept" style="width: 60px; height: 28px" class="button1" />&nbsp;<input type="submit" id="denyRequest" value="Deny" style="width: 50px; height: 28px" class="button1" /></span>');
    				});
    			</script>
    <?php } } ?>


  [1]: http://i.stack.imgur.com/41uWd.png