Re: Populating multi-select list from mysql
| From: | Adam Royle | Date: | Sat, 22 Jun 2002 02:52:18 +0000 |
| Subject: | Re: Populating multi-select list from mysql | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-19990@lists.php.net to get a copy of this message | ||
Hi Bob,
I have written some functions which make select lists much easier. I have two functions:
- BuildQuickSelect() - you pass a couple of parameters (tablename, etc)
- BuildSelectMenu() - you pass $sql and some more parameters
Unfortunately, they require a few things (such as other functions I have written). Fortunately, I have them all in one lib.php file, and you are welcome to use it. I think you will find it very handy and time-saving. I COULDN'T do without them. Look through the whole file, and you might see some other handy ones in there too.
There are four variables at the top of the lib.php file, which you must set according to your server setup (server, username, password, etc).
To use the stuff, simply include() it at the top of each page.
And to solve your problem (using the lib.php file), all you have to do is this:
BuildQuickSelect("category_list_array[]","categories","","multiple size=10");
And voila... all is done...
Need any help... ask
Oh yeah, btw everyone else, I have emailed the lib.php file to Bob - if you want a copy, email me.
Adam
Attachment: [application/zip] lib.php.zip
Attachment: [application/zip] lib.php.zip