PHP if/else not working as intended <p>Below is some code I am using to check if a field says "CIT" to display that as the selected item in the html select box. Elseif the field says "CSE", display "CSE" as selected and CIT/CSE in the drop downs respectively if one or the other is selected in the database. No matter what is in the database field the code always seems to use the first if statement. So courses with "CSE" as course_major are showing "CIT" as the first option in the drop down, however it shouldn't be this way.</p> <pre><code>while ($row = mysqli_fetch_array ($r, MYSQLI_ASSOC)) { $bg = ($bg=='#B39C56' ? '#000000' : '#0A0A0A'); echo '&lt;tr&gt; &lt;form action="edit_course.php" method="post"&gt; &lt;!--Next Course First Line of Table --&gt;&lt;td&gt;Major:&lt;/td&gt; &lt;td style="text-align:left"&gt;'; if ($row['course_major'] = "CIT") { echo' &lt;select name="course_major" class="rounded"&gt; &lt;option value="'.$row['course_major'].'"&gt;'.$row['course_major'].'&lt;/option&gt; &lt;option value="CSE"&gt;CSE&lt;/option&gt; &lt;/select&gt;'; } elseif ($row['course_major'] = "CSE") { echo' &lt;select name="course_major" class="rounded"&gt; &lt;option value="'.$row['course_major'].'"&gt;'.$row['course_major'].'&lt;/option&gt; &lt;option value="CIT"&gt;CIT&lt;/option&gt; &lt;/select&gt;'; }; echo'&lt;/td&gt; ........................ </code></pre>