|I'm quite new to PHP. I have a selection dropdown, which sends the data to the phpmyadmin database.
This works fine, but I'd like it to be selected as default when I'm opening it again.
Here is how my code currently looks like:
<?php while ($category = mysqli_fetch_assoc($categories)) : ?>
<option value="<?= $category['id'] ?>"><?= $category['title'] ?></option>
<?php endwhile ?>
What I have tried:
<option value="<?= $category['id'] ?>"><?= $category['title'] ? "selected" : ""?></option>
I basically just inserted "selected" into it, but it's not the correct way, because every single option is shown as "selected".
Here is an image about the frontend:
Does anyone know how to make it to work?
Thank you for being here!