user225269
user225269

Reputation: 10913

How to load mysql data on option html form

I have this option form:

<tr>
<td><font size="3">Civil Status</td>
<td>:</td>
<td>
    <select name="cs" id="cs">
        <option>Single</option>
        <option>Married</option>
        <option>Widowed</option>

    </select></td></td>

What do I do in order to load it with mysql data, like this one:

<td width="23"><font size="3">Sex</td>
<td width="3">:</td>
<td width="174"><input name="sex" type="text"  maxlength="1" value="<?php echo $row["SEX"]; ?>"></td>

Upvotes: 1

Views: 3658

Answers (1)

Adrian Schmidt
Adrian Schmidt

Reputation: 1885

$result = mysql_query(blahblah);

<select name="cs" id="cs">
    <?php
    while ($line = mysql_fetch_array($result)) {
        echo '<option value="' . $line['id'] . '">' . $line['name'] . '</option>';
    }
    ?>
</select>

Something like that should do it. If I understood the question correctly...

Upvotes: 2

Related Questions