I am trying to move MySQL data to an HTML "<SELECT......" field. Inserting code such as <?php echo htmlspecialchars($row["S_NameLast"]); ?> into the value of an "<input...." field works fine. As I said, I can't get it working for a "select" field.

    A little example:

    <select name="sel">
    <?php
    $sql = "SELECT S_NameLast FROM table";
    $result = mysql_query($sql);
    while ($r = mysql_fetch_assoc($result)) {
        echo '<option value="'.$r['S_NameLast'].'">'.$r['S_NameLast'].'</option>';
    }
    ?>
    </select>
    

      I applied the code to my work and it WORKS!

      Thanks a lot!

        Write a Reply...