Hello, I’m populating a select with data from my database table. In the table I have four columns some of the columns have lots of data others don’t.
Now I’m only extracting them by categorys to the selects, but I’ve noticed when you open the select that blanks from table also creates and option for it.
This is the code for better understanding:
<select class="form-select w-75" name="projecttype" required>
<option></option>
<?php foreach($result as $data): ?>
<option value="<?php echo $data['projectoptions'] ?>"><?php echo $data['projectoptions'] ?></option>
<?php endforeach ?>
</select>
the output:
I got lots of empty white space in the select.
I’ve red about range(), but I think I’m not understand it correctly. Since I know the amount of data in that column is 8. How do I set it to stop at 8 and not continue with the blank spaces?