开发者

Poplate html drop down box

开发者 https://www.devze.com 2022-12-24 04:59 出处:网络
EDIT: THANKS - I MANAGED IT IN THE END SHOULD HAVE TRIED FOR LONGER BEFORE POSTING SORRY how do you populate a drop down html box within a form, but populate it with values from a php array

EDIT: THANKS - I MANAGED IT IN THE END

SHOULD HAVE TRIED FOR LONGER BEFORE POSTING

SORRY

how do you populate a drop down html box within a form, but populate it with values from a php array

for example

<form name="mname" action="index.php" method="post">
<select name='values'>
<option> </option>
<option> </option>
</form>

i can do it by echoing it out, thus not needing the form, but i really need to get at the value i am echoing in th开发者_如何学Goe drop down box later, so was hoping someone could show me how it can be done like this, using php


<?php
    foreach ($myArray as $value) {
        $checked = ($_GET['values'] == $value) ? " checked" : "";
        $saveValue = htmlspecialchars($value);
        print "<option$checked>$safeValue</option>";
    }
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号