hi guys,

i wonder if someone could help, i am teaching myself

with tutorials and online books etc PHP, ive played around in it before, but due to time i couldn't get into it. now im going headlong into it.
anyway moving on, the problem i have is, i have a racers booking in record.

for example looks like
Racer: name
Committee: name
etc etc

basically, the racer books in via the committee member.
now what i want to do is to be able to edit the form, so that on the edit page, the committee member is a drop down box (this i can do) bce1a0e2c11cee5ca0e8d29ac3ed78b3

but i cannot seem to get it to auto select the committee member that has taken the book in, instead it just defaults to the first committee member.
b38fc9ad38263ad789be2325e3bf1441

any ideas?

        $sql_com = "SELECT * FROM tbl_Committee";
        $res_com = mysql_query($sql_com) or die ("emps". mysql_error());
        ?>
    <tr><td>Committee: </td><td>
    <?php
        $dropdown = "<select name='committee'>";

        while($row_com = mysql_fetch_assoc($res_com)) {
            $dropdown .= "\r\n<option value='{$row_com['com_FirstName']}'>{$row_com['com_FirstName']}</option>";
        }

        $dropdown .= "\r\n</select>";
        echo $dropdown;
        ?>

The option that should be selected has to have a selected="selected" attribute. To find out which one it is, you do a check in each iterration. Suppose that com_FirstName is the criteria as in your example:

// committee member that has taken the book in
$comiteMemeber = 'John';
while($row_com = mysql_fetch_assoc($res_com)) {
    $dropdown .= "\r\n<option value='{$row_com['com_FirstName']}'>{$row_com['com_FirstName']}";
    // here you do the check
    if($row_com['com_FirstName'] == $comiteMemeber) {
        $dropdown .= ' selected="selected"';
    }
    $dropdown .= ">{$row_com['com_FirstName']}</option>";
    </option>";
}

hi mate, thanks for you reply...
I see your point :) thank you, totally missed that, can't seem to get that code working tho, i think im missing something, will keep tweaking and playing

Hi Broj1,
i have tried tweaking that code, but couldn't get it to work, does it work for you?

UPDATE: got it pulling in, but it duplicates the committee member, will continue to work on it, unless any 1 has any ideas

Maybe you post a little bit more code. At least to see where is the information about the ommittee member that has taken the book in.

Try to Use distinct keyword in your query

$dropdownquery="select distinct col1,col2 ....";

Hi urtrivedi, thanks for the idea, i will try that also :)

Broj1, code sorted now, it was me being an idiot, trying to code as soon as i wake up, missing silly things :) thanks for your help :)

commented: Can happen to anyone :-) +11
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.