Answers for "php select option selected from database"

PHP
5

php select option

// Page containing a form:
<form action="myaction.php" method="post">
 <select name="fruit">
    <option value="Apple">Apple</option>
    <option value="Banana">Banana</option>
 </select>  
 <input type="submit" value="Submit">
</form>

// myaction.php
Hello <?php echo htmlspecialchars($_POST['fruit']); ?>
Posted by: Guest on June-20-2021
0

php select option selected from database

<?php

$selection = array('PHP', 'ASP');
echo '<select>
      <option value="0">Please Select Option</option>';

foreach ($selection as $selection) {
    $selected = ($options == $selection) ? "selected" : "";
    echo '<option '.$selected.' value="'.$selection.'">'.$selection.'</option>';
}

echo '</select>';
Posted by: Guest on July-09-2021

Code answers related to "php select option selected from database"

Browse Popular Code Answers by Language