Re: Dropdowns
| From: | Paul DuBois | Date: | Thu, 01 Jun 2000 15:24:29 +0000 |
| Subject: | Re: Dropdowns | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-818@lists.php.net to get a copy of this message | ||
At 12:39 PM +0930 2000-06-01, David Robley wrote:
On 31 May, Scott Iwamoto wrote:The variable reference inside single quotes won't be evaluated. One thing that seems not yet to have been pointed out: $publication is an array. You need to access the member of the array that you want. So you may want something like this: $val = $publication["str_publication"]; echo "<option value=\"$val\">$val</option>"; I've added the closing </option> tag, too. If your values may contain characters that are special in HTML such as <, >, or &, then you should probably extract your value like this: $val = htmlspecialchars ($publication["str_publication"]); -- Paul DuBois, paul@snake.netI 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) {Shouldn't that be something likeprint "<option>". $publication;echo '<option value="$publication">' . $publication;