Re: always last
| From: | Andrey Hristov | Date: | Thu, 23 Aug 2001 15:33:53 +0000 |
| Subject: | Re: always last | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-64113@lists.php.net to get a copy of this message | ||
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" <jeremy@prepresshelp.com>
To: <php-general@lists.php.net>
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: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>