Use a counter when fetching from the DB
if you use while the
$counter=0;
while(list(...)=mysql_fetch_array($res)){
    $option_block .= '<option '.(($counter==0)? '
selected':'').'>'.$option.'</option>';
}

Andrey Hristov
IcyGEN Corporation
http://www.icygen.com
99%

----- Original Message -----
From: "Jeremy Morano" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 23, 2001 6:10 PM
Subject: [PHP] always last


> Hi,  I need a little bit of help.
> My variable $team in the option block is always set to the last variable
> that is read....I would like it to contain the option that the user
> clicks.....Please help me!
>
>
>
> My Select works properly
>
> ...
>
>
> $result = @mysql_query($sql,$connection) or die("Couldn't execute
query.");
>
>
> while ($row = mysql_fetch_array($result)) {
> $uid = $row['uid']
> $team = $row['team'];
>
>
> $option_block .= "<option value=\"$uid\">$team</option>";
> }
>
> $display_block = "
>
> <FORM METHOD=\"post\" ACTION=\"show_makeapick.php\">
>
> <P><strong>Team:</strong>
> <select name=\"uid\">
> $option_block
> </select>
>
> <INPUT TYPE=\"SUBMIT\" NAME=\"submit\" VALUE=\"Select this Team\"></P>
> </form>
>
> ";
>
> ?>
>
> <HTML>
> <HEAD>
> <TITLE>User Management: Modify a User</TITLE>
> </HEAD>
> <BODY>
> <h1>User Management</h1>
> <h2><em>Modify a User</em></h2>
> <P>Select a contact from the list below, to modify the user's record.</p>
>
> <? echo "$display_block"; ?>
>
> <p><a href="contact_menu3.php">Return to Main Menu</a></p>
>
> </BODY>
> </HTML>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to