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'];?>"
<?php
$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";
else
//if blank display first item in dropdown list
echo "<option value=\"$tempdeptcode\">$tempdeptcode ($tempdeptname) </option>\n";
}
}
?>
endwhile;
</select>
</div>
This works perfectly other than not showing row 0.
Thanks in advance.