Re: Dropdowns
| From: | Ray Black III | Date: | Fri, 02 Jun 2000 19:58:37 +0000 |
| Subject: | Re: Dropdowns | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-921@lists.php.net to get a copy of this message | ||
About the closing option tag, that is indeed optional, according to the W3C
standards...
http://www.w3.org/TR/html4/interact/forms.html#h-17.6.1
More importantly, mysql_fetch_array() returns things in a 2-D associative
array, so my approach has always been to do the query in the header/at the
top of the page, and then deal with the data in the array further down in
the page:
<?
$db_pull = mysql_query( "$query" );
for ($foo = 0; $foo < mysql_num_rows( $db_pull ); $foo++)
$arr[] = mysql_fetch_array( $db_pull );
?>
<html>
...
...
<?
for ($foo = 0; $foo < sizeof($arr); $foo++)
{
$arr[$foo]['FieldName'];
...
}
?>
...
...
</html>
Thats the way that /I/ deal with it, anyway ;)
-r3-
----- Original Message -----
From: Eric McKeown <ericm@palaver.net>
To: <php-general@lists.php.net>
Sent: Friday, June 02, 2000 3:33 PM
Subject: Re: [PHP-GENERAL] Dropdowns
> Maxwell Hung wrote:
>
>
> > your html is wrong, when you use the option tag you
> > need a value for the option then a title for it. A bit
> > like an <a > tag.
>
> The VALUE attribute is optional. You can write OPTION tags with or
> without
> the VALUE attribute, and if you leave it off, the value of the selected
> option will be that which follows the OPTION tag and precedes the
> beginning
> of the next OPTION tag. For instance....
>
> <SELECT NAME="bogus">
> <OPTION>Option 1
> <OPTION>Option 2
> </SELECT>
>
> In this case, if the user selects the first option, the value of $bogus
> on
> the next page will be "Option 1", and if he selects the second option,
> it
> will be "Option 2". Closing the <OPTION> tag is optional with every
> browser I've ever worked with, which admittedly is not all of them.
>
>
> >
> >
> > mysql_fetch_array also returns an array of your
> > results so calling $publication will not print the
> > results that you want.
>
> I'm in agreement on this point. You need to extract the individual
> pieces
> of the array instead of just trying to print out the array as a whole.
> I think fixing this ought to fix the problem entirely.
>
> My $0.02.
>
> Eric
>
>
> >
> >
> > try this: I always select the db before so you will
> > need to mod that bit.
> >
> > echo "<select name=\"publication\">\n";
> > $query = mysql_query("SELECT str_publication FROM
> > publication");
> > while ($result= mysql_fetch_array($query)) {
> > echo "<option value=\"" .
> > $result["str_publication"]
> > . "\">" . $result["str_publication"] .
> > "</option>\n";
> > }
> > echo "</select>\n";
> >
> > The new line will only make a difference if you view
> > the source it will have no effect on what you see in
> > your browser.
> >
> > M@
> >
>
> --
> 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