lundi 11 juillet 2016

Drop down - show previously selected in loop

my problem is to show previously selected in a while loop. I found a way to do it in not-loop setup, but a loop is a problem for me.

The following code give me a drop down of countries (and country code):

<?php 

foreach($countries as $key => $value) { ?>

<option value="<?= $value . ' ' . $key ?>" title="<?= htmlspecialchars($value) ?>"><?= htmlspecialchars($value) ?></option>

<?php } ?>

And it works good. But imagine someone edit their country, thus I would love to show previously selected country. Of course I have a variable with the specific previously selected country... Thanks.

Aucun commentaire:

Enregistrer un commentaire