Re: Dropdowns
| From: | Maxwell Hung | Date: | Thu, 01 Jun 2000 23:50:43 +0000 |
| Subject: | Re: Dropdowns | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-881@lists.php.net to get a copy of this message | ||
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.
mysql_fetch_array also returns an array of your
results so calling $publication will not print the
results that you want.
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@
--- David Treves <dwork@macam98.ac.il> wrote: > Hi
there,
> when you add options to the select tag you have
> to start a new line for
> every option, meaning that you need to add in the
> end of your echo the "\n"
> in order to force a new line in the source of the
> HTML. Otherwise, the whole
> output will be given in one line.
>
> Hope I helped!
> David.
>
> ----- Original Message -----
> From: Scott Iwamoto <scott@cns.queens.org>
> To: <php-general@lists.php.net>
> Sent: Thursday, June 01, 2000 5:56 AM
> Subject: [PHP-GENERAL] Dropdowns
>
>
> >
> > I am trying to make a dropdown from values in a
> table but I keep
> > getting errors. I have checked a number of the
> archives. I found
> > various functions that are supposed to do this yet
> I just cant seem
> > to get it to work.
> >
> > Any help/tips would be greatly appreciated. It
> would help to see the
> > full source of a working copy so I can get a
> better understanding of
> > how it works. =) Thanks.
> >
> >
> > I tried to break it down to something simple but
> even this does not
> > seem to work.
> >
> >
> > <html>
> > <head>
> > <title Array into SELECT dropdown </title>
> > </head>
> > <body>
> > <?php
> >
> > $user = "phpuser";
> > $password = "phppassword";
> > $host = "localhost";
> > $table = "publications";
> > $database = "publications";
> > ?>
> >
> > <form method="post" action="mysql_test.php3">
> > <select name="publication">
> > <?
> > mysql_connect($host, $user, $password);
> >
> > $result = mysql_db_query($database, "select
> str_publication from
> publication");
> >
> > while($publication = mysql_fetch_array($result) {
> > print "<option>". $publication;
> >
> > }
> > ?>
> > </select>
> > <input type=submit name=submit>
> > </form>
> > </body>
> > </html>
> >
> >
> >
> >
> >
> >
> >
> >
> > Scott T. Iwamoto, Coordinator Departmental
> Information Systems,
> > Research Planning & Development, The Queen's
> Medical Center
> > 1356 Lusitana St. 8th Floor, Honolulu, HI 96813
> > (808) 537-7937 Fax: (808) 537-7898
> > http://www.d2p.queens.org
> >
> >
> >
> >
> >
> >
> >
> > --
> > 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
> >
> >
>
>
> --
> 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
>
__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/