This will show your result from saved data as the first in a dropdown of other results.
On its first loop it will add something in the beginning, then add the rest.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
$sql = "SELECT * FROM clientskeywords WHERE myclientid=$clientid"; if(!$result = $mysqli->query($sql)){ die('There was an error running the query [' . $mysqli->error . ']'); } <select id="keyworddropdown" name="kdropdown" class="form-control"> <?php $kcount =0; while($row = mysqli_fetch_array($result)) { if ($row['keyword']!=""){ if ($kcount==0) { echo "<option value=".$row['keyword']." selected='selected'>".$keyword[$key]."</option>"; //only runs once } echo "<option value='".$row['id']."'>".$row['keyword']."</option>"; } $kcount=$kcount+1; } ?> </select> |