I am using bootstrap modals, when i query to populate a dropdown to fill in to my form, my query is show all but the first record and i can't figure out why.

My form looks like this

<div class="form-group">
            <label for="deptcode">Department</label>
                <select class="form-control" id="deptcode" name="deptcode" value="<?php echo $mem['deptcode'];?>"
                    $departments = $mysqli->query("Select * FROM department ORDER BY deptcode");
                     while ($dept = mysqli_fetch_assoc($departments)){

                       $tempdeptname = $dept['deptname'];
                       $tempdeptcode = $dept['deptcode'];
                       //see what the current name is and display it first
                       if ($tempdeptcode == $mem['deptcode'])
                         echo "<option value='$tempdeptcode' selected='selected'>$tempdeptcode ($tempdeptname) </option>\n";
                       //if blank display first item in dropdown list
                       echo "<option value=\"$tempdeptcode\">$tempdeptcode ($tempdeptname) </option>\n";

This works perfectly other than not showing row 0.

Thanks in advance.

Disregard, right after i posted this i noticed i was missing a bracket, elusive little creatures. Sorry for the post.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.