jason360 Posted December 9, 2013 Share Posted December 9, 2013 Hey guys, I have an series of if statements that I believe to be correct, comparing to examples I have found. Anyway, the first 2 parts of the if statement work providing "Content #1" and "Content #2", however "Content #3" will not echo out. Instead of getting Content #3 it looks like I am getting a variation of Content #2. Any ideas what I am doing wrong here? Thank you! if($d['user_id'] == $_SESSION['user_id']):{ $result = mysql_query( "SELECT member_vote FROM member_rank WHERE member_id=".$d['user_id']."" ); list($vote) = mysql_fetch_array( $result ); return ' <div id="comment" > Content #1 </div> ';} elseif($d['user_id'] != $_SESSION['user_id']):{ $result = mysql_query( "SELECT member_vote FROM member_rank WHERE member_id=".$d['user_id']."" ); list($vote) = mysql_fetch_array( $result ); return ' <div id="comment" > Content #2 </div> ';} else: { $result = mysql_query( "SELECT member_vote FROM member_rank WHERE member_id=".$d['user_id']."" ); list($vote) = mysql_fetch_array( $result ); return ' <div id="comment" > Content #3 </div> ';} endif; Link to comment https://forums.phpfreaks.com/topic/284664-if-statement-issue/ Share on other sites More sharing options...
mac_gyver Posted December 9, 2013 Share Posted December 9, 2013 you are comparing $d['user_id'] with $_SESSION['user_id']. for equal/not-equal, there are only two choices. they either are equal to each other or they are not. Link to comment https://forums.phpfreaks.com/topic/284664-if-statement-issue/#findComment-1461864 Share on other sites More sharing options...
jason360 Posted December 10, 2013 Author Share Posted December 10, 2013 Thanks again mac_gyver! I added "empty($_SESSION['user_id']) &&" to my if statements, so that if the $_SESSION['user_id'] is empty it goes to my else statement. Link to comment https://forums.phpfreaks.com/topic/284664-if-statement-issue/#findComment-1462002 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.