I use this function:

       function ListboxMatch($size, $name, $query, $matchtothis) 
           {
             //echo "<BR>".$query."<BR>";
           if ( $qry = mysql_query($query) )
                   {
                   if (mysql_num_rows($qry) > 0)
                   {
                        echo "<SELECT SIZE='".$size."'
NAME='".$name."'>\n\t<OPTION VALUE=''>\n";
                                while (list($value, $text, $description)
= mysql_fetch_row($qry))
                                {
                        echo "\t<OPTION VALUE='".$value."'";
                                        if ($value == $matchtothis) {
echo " SELECTED"; }
                                        echo ">";
                                        echo stripslashes($text);
                                                if ($description) echo "
(".stripslashes($description).")";
                                        echo "\n";
                                }
                      echo "</SELECT>";
                   }
                           else echo "No data for Listbox\n";
                   mysql_free_result($qry);
                   }
                   else echo "Listbox cannot be built because of an
invalid SQL query.";
       } /* end ListboxMatch */



And use it like this:

<?php ListboxMatch(1, "edit_booth_id", "SELECT booth_id, booth_name,
booth_number FROM Booth_Table ORDER BY booth_name, booth_number",
$edit_booth_id); ?> 


DÆVID.
http://daevid.com

> -----Original Message-----
> From: Natividad Castro [mailto:[EMAIL PROTECTED]] 
> Sent: Thursday, May 30, 2002 1:53 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] drop down menu
> 
> 
> Hi to all,
> how can I display information in a drop down menu?
> 
> What I want to do is: select all the values from info_sys 
> field and display them in a drop down menu.
> 
> This is what I have so far, but only display one value at a 
> time. $sql = mysql_query("SELECT info_sys from project order 
> by project_id, project_id ASC"); while($query_data = 
> mysql_fetch_array($sql)) { $info_sys = $query_data[info_sys]; 
> } <select name="info_sys"> <option><? echo $info_sys; 
> ?></option> </select>
> 
> Any help is greatly appreciate
> 
> Thanks in advanced
> Nato


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to