table: request
id friend_id candidate_id
== ============== ==============
1 20180928115958 20180925112428
2 20181008181142 20180925112428
3 20180928115958 20181008181142
4 20181010181207 20180928115958
5 20181008181142 20181010181207
6 20181010181207 20180925112428
Query
<?php
$_SESSION['candidate_id']=20181010181207;
$sql_ac = mysqli_query($con,"select friend_id,candidate_id from request where candidate_id='".$_SESSION['candidate_id']."' or friend_id='".$_SESSION['candidate_id']."'");
while($row_ac = mysqli_fetch_array($sql_ac))
{
if($row_ac['friend_id']==$_SESSION['candidate_id'] && $row_ac['candidate_id']==$_SESSION['candidate_id'])
{
echo "";
}
else
{
echo $row_ac['friend_id']."<br/><br/>";
echo $row_ac['candidate_id']."<br/><br/>";
}
}
?>
Unexpected output:
20181010181207
20180928115958
20181008181142
20181010181207
20181010181207
20180925112428
Expected Output
20180928115958
20181008181142
20180925112428
In this code I have table request which have two key field i.e. friend_id and candidate_id. Now, I $_SESSION['candidate_id']='20181010181207'. So, How can I get expected output as I have mention above? Please help me.
Thank You
20181010181207 20180928115958 20181010181207 20180925112428@MickaelLegerfriend_idwhencandidate_idmatches and vice versa whenfriend_idmatches?if(($row_ac['friend_id'] != $_SESSION['candidate_id'] { echo $row_ac['friend_id'] }- same for conadidate_id20181010181207present in bothfriend_idandcandidate_id. it will not show