I can’t seem to get the elseif to process in the below php code. My database setup is noted below:

<?php // the following php is the bootstrapper for the friendship connector
$selectedId = $_REQUEST['id'];
$myuserid = $this->session->userdata('userid');
$friendshipQuery = $this->db->query("SELECT * FROM friends");
$row = $friendshipQuery->row();
foreach ($friendshipQuery->result() as $row) {
if ($myuserid == $selectedId) { ?>
<script type="text/javascript">
$(document).ready(function() {
$("#addFriend").hide();
});
</script>
<?php } elseif ($row->relationType == 'requested') { ?>
<script type="text/javascript">
$(document).ready(function() {
alert("hello");
$("#addFriend").replaceWith(<input type="submit" value="Accept Friend" style="width: 95px; height: 28px" class="button1" />);
});
</script>
<?php } } ?>
Your problem is right here:
Your assigning the query as a ->row() element. Take that line out and on the foreach just add this:
That should solve it.