RE: [PHP] populate form input option dropdown box from existing data

2009-06-18 Thread Ford, Mike
On 17 June 2009 15:01, PJ advised: It does, indeed. This confirms my inexperienced conclusion that in_array() does not work on associative arrays per se; it works on simple arrays and I just don't have the experience to think of extracting only the id fields. Let's squash this misconception

RE: [PHP] populate form input option dropdown box from existing data

2009-06-18 Thread Ford, Mike
On 17 June 2009 14:30, PJ advised: For the moment, I am trying to resolve the problem of extracting a value from a string returned by a query. I thought that in_array() would do it, but the tests I have run on it are 100% negative. The only thing I have not used in the tests is third

Re: [PHP] populate form input option dropdown box from existing data

2009-06-18 Thread Peter Ford
PJ wrote: I'm including the relevant code: // select categories for book to be updated $sql = SELECT id, category FROM categories, book_categories WHERE book_categories.bookID = '$bid' book_categories.categories_id = categories.id; if ( ( $results = mysql_query($sql, $db) ) ) {

Re: [PHP] populate form input option dropdown box from existing data

2009-06-18 Thread PJ
Stuart wrote: 2009/6/18 PJ af.gour...@videotron.ca: I snipped to make it short... continue at bottom... Step back from the code and consider the steps you need to perform... 1) Get an array of the categories, ideally in the form $cats[catid] = categoryname. 2) Get an array of the

Re: [PHP] populate form input option dropdown box from existing data

2009-06-18 Thread PJ
Ford, Mike wrote: On 17 June 2009 15:01, PJ advised: It does, indeed. This confirms my inexperienced conclusion that in_array() does not work on associative arrays per se; it works on simple arrays and I just don't have the experience to think of extracting only the id fields.

Re: [PHP] populate form input option dropdown box from existing data

2009-06-18 Thread Martin Scotta
It is a sintax error if (in_array($ex, $selected) --- missing ) echo br /yes; else echo br /no; On Thu, Jun 18, 2009 at 10:13 AM, PJ af.gour...@videotron.ca wrote: Ford, Mike wrote: On 17 June 2009 14:30, PJ advised: For the moment, I am trying to resolve the problem of

Re: [PHP] populate form input option dropdown box from existing data

2009-06-18 Thread PJ
Martin Scotta wrote: It is a sintax error if (in_array($ex, $selected) --- missing ) echo br /yes; else echo br /no; On Thu, Jun 18, 2009 at 10:13 AM, PJ af.gour...@videotron.ca mailto:af.gour...@videotron.ca wrote: Ford, Mike wrote: On 17 June 2009 14:30, PJ advised:

Re: [PHP] populate form input option dropdown box from existing data

2009-06-18 Thread Stuart
2009/6/18 PJ af.gour...@videotron.ca: Martin Scotta wrote: It is a sintax error if (in_array($ex, $selected)   --- missing ) echo br /yes; else echo br /no; On Thu, Jun 18, 2009 at 10:13 AM, PJ af.gour...@videotron.ca mailto:af.gour...@videotron.ca wrote:     Ford, Mike wrote:     On

Re: [PHP] populate form input option dropdown box from existing data

2009-06-18 Thread PJ
Stuart wrote: 2009/6/18 PJ af.gour...@videotron.ca: Martin Scotta wrote: It is a sintax error if (in_array($ex, $selected) --- missing ) echo br /yes; else echo br /no; On Thu, Jun 18, 2009 at 10:13 AM, PJ af.gour...@videotron.ca mailto:af.gour...@videotron.ca wrote:

RE: [PHP] populate form input option dropdown box from existing data

2009-06-17 Thread Ford, Mike
On 16 June 2009 20:48, PJ advised: Now, I was happy to learn that it is simpler to populate the insert new books page dynamically from the db. Much shorter neater. It looks to me like the best solution for the edit page is close to what Yuri suggests. Since the edit page is very similar

RE: [PHP] populate form input option dropdown box from existing data

2009-06-17 Thread Yuri Yarlei
:16:15 +0100 From: m.f...@leedsmet.ac.uk To: php-general@lists.php.net Subject: RE: [PHP] populate form input option dropdown box from existing data On 16 June 2009 20:48, PJ advised: Now, I was happy to learn that it is simpler to populate the insert new books page dynamically from

RE: [PHP] populate form input option dropdown box from existing data

2009-06-17 Thread Yuri Yarlei
-0400 From: af.gour...@videotron.ca To: a...@ashleysheridan.co.uk CC: gargari...@hotmail.com; m...@dajve.co.uk; php-general@lists.php.net; tedd.sperl...@gmail.com; nos...@mckenzies.net Subject: Re: [PHP] populate form input option dropdown box from existingdata Ashley Sheridan

Re: [PHP] populate form input option dropdown box from existing data

2009-06-17 Thread PJ
Ashley Sheridan wrote: On Tue, 2009-06-16 at 20:46 -0400, PJ wrote: Ashley Sheridan wrote: On Tue, 2009-06-16 at 18:19 -0400, PJ wrote: Ashley Sheridan wrote: On Tue, 2009-06-16 at 15:48 -0400, PJ wrote: jenai tomaka wrote:

Re: [PHP] populate form input option dropdown box from existing data

2009-06-17 Thread PJ
Ford, Mike wrote: On 16 June 2009 20:48, PJ advised: Now, I was happy to learn that it is simpler to populate the insert new books page dynamically from the db. Much shorter neater. It looks to me like the best solution for the edit page is close to what Yuri suggests. Since the edit

Re: [PHP] populate form input option dropdown box from existing data

2009-06-17 Thread Ashley Sheridan
On Wed, 2009-06-17 at 10:01 -0400, PJ wrote: Ford, Mike wrote: On 16 June 2009 20:48, PJ advised: Now, I was happy to learn that it is simpler to populate the insert new books page dynamically from the db. Much shorter neater. It looks to me like the best solution for the edit page

Re: [PHP] populate form input option dropdown box from existing data

2009-06-17 Thread Shawn McKenzie
PJ wrote: It does, indeed. This confirms my inexperienced conclusion that in_array() does not work on associative arrays per se; it works on simple arrays and I just don't have the experience to think of extracting only the id fields. I actually am using a slightly more complicated if else

Re: [PHP] populate form input option dropdown box from existing data

2009-06-17 Thread PJ
Ashley Sheridan wrote: On Wed, 2009-06-17 at 10:01 -0400, PJ wrote: Ford, Mike wrote: On 16 June 2009 20:48, PJ advised: Now, I was happy to learn that it is simpler to populate the insert new books page dynamically from the db. Much shorter neater. It looks to me like

Re: [PHP] populate form input option dropdown box from existing data

2009-06-17 Thread Shawn McKenzie
PJ wrote: Ashley Sheridan wrote: On Wed, 2009-06-17 at 10:01 -0400, PJ wrote: Ford, Mike wrote: On 16 June 2009 20:48, PJ advised: Now, I was happy to learn that it is simpler to populate the insert new books page dynamically from the db. Much shorter neater. It looks

Re: [PHP] populate form input option dropdown box from existing data

2009-06-17 Thread Ashley Sheridan
On Wed, 2009-06-17 at 16:29 -0400, PJ wrote: Ashley Sheridan wrote: On Wed, 2009-06-17 at 10:01 -0400, PJ wrote: Ford, Mike wrote: On 16 June 2009 20:48, PJ advised: Now, I was happy to learn that it is simpler to populate the insert new books page dynamically

Re: [PHP] populate form input option dropdown box from existing data

2009-06-17 Thread PJ
'], /optionbr /; } } I think it will work now. Thanks much for the input the support. :-) Date: Wed, 17 Jun 2009 10:16:15 +0100 From: m.f...@leedsmet.ac.uk To: php-general@lists.php.net Subject: RE: [PHP] populate form input option dropdown box from existing data

Re: [PHP] populate form input option dropdown box from existing data

2009-06-17 Thread PJ
Shawn McKenzie wrote: PJ wrote: Ashley Sheridan wrote: On Wed, 2009-06-17 at 10:01 -0400, PJ wrote: Ford, Mike wrote: On 16 June 2009 20:48, PJ advised: Now, I was happy to learn that it is simpler to populate the insert new books page dynamically from the db. Much shorter neater. It

Re: [PHP] populate form input option dropdown box from existing data

2009-06-17 Thread Stuart
Oops, hit reply instead of reply to all. Sorry for the duplicate PJ. 2009/6/17 PJ af.gour...@videotron.ca: Shawn McKenzie wrote: PJ wrote: Ashley Sheridan wrote: On Wed, 2009-06-17 at 10:01 -0400, PJ wrote: Ford, Mike wrote: On 16 June 2009 20:48, PJ advised: Now, I was happy to learn

Re: [PHP] populate form input option dropdown box from existing data

2009-06-17 Thread PJ
I snipped to make it short... continue at bottom... Step back from the code and consider the steps you need to perform... 1) Get an array of the categories, ideally in the form $cats[catid] = categoryname. 2) Get an array of the category IDs that should be selected, i.e. $selectedcats =

Re: [PHP] populate form input option dropdown box from existing data

2009-06-17 Thread Stuart
2009/6/18 PJ af.gour...@videotron.ca: I snipped to make it short... continue at bottom... Step back from the code and consider the steps you need to perform... 1) Get an array of the categories, ideally in the form $cats[catid] = categoryname. 2) Get an array of the category IDs that should

RE: [PHP] populate form input option dropdown box from existing data

2009-06-16 Thread Dajve Green
-Original Message- From: PJ [mailto:af.gour...@videotron.ca] Sent: 15 June 2009 23:10 To: php-general@lists.php.net Subject: [PHP] populate form input option dropdown box from existing data I am having difficulties figuring out how enter retrieved data into a dropdown box for

Re: [PHP] populate form input option dropdown box from existing data

2009-06-16 Thread kranthi
the above post points to a 404 page any ways as suggested above in_array() will do the trick for you. i prefer using a template engine like smarty.. http://www.smarty.net/manual/en/language.function.html.options.php One line of code and you are done -- PHP General Mailing List

RE: [PHP] populate form input option dropdown box from existing data

2009-06-16 Thread jenai tomaka
] populate form input option dropdown box from existing data -Original Message- From: PJ [mailto:af.gour...@videotron.ca] Sent: 15 June 2009 23:10 To: php-general@lists.php.net Subject: [PHP] populate form input option dropdown box from existing data I am having difficulties

Re: [PHP] populate form input option dropdown box from existing data

2009-06-16 Thread tedd
At 6:09 PM -0400 6/15/09, PJ wrote: I am having difficulties figuring out how enter retrieved data into a dropdown box for editing. Here's a snippet: ...snip select name=categoriesIN[] multiple size=8 option value=1Civilization/option option value=2Monuments, Temples amp;

RE: [PHP] populate form input option dropdown box from existing data

2009-06-16 Thread Dajve Green
...@dajve.co.uk; af.gour...@videotron.ca; php-general@lists.php.net Subject: RE: [PHP] populate form input option dropdown box from existing data You can try like this, $row = stored data; and write the options like this option value=id (id == $row ? selected : ) /option Yuri Yarlei

RE: [PHP] populate form input option dropdown box from existing data

2009-06-16 Thread Dajve Green
A *multiple* select control, as in Phil's initial request will return an array, however. -Original Message- From: tedd [mailto:tedd.sperl...@gmail.com] Sent: 16 June 2009 15:58 To: PJ; php-general@lists.php.net Subject: Re: [PHP] populate form input option dropdown box from existing

Re: [PHP] populate form input option dropdown box from existing data

2009-06-16 Thread PJ
jenai tomaka wrote: You can try like this, $row = stored data; and write the options like this option value=id (id == $row ? selected : ) /option Yuri Yarlei. http://brasil.microsoft.com.br/IE8/mergulhe/?utm_source=MSN%3BHotmailutm_medium=Taglineutm_campaign=IE8 Yuri, I'm still

Re: [PHP] populate form input option dropdown box from existing data

2009-06-16 Thread Ashley Sheridan
On Tue, 2009-06-16 at 15:48 -0400, PJ wrote: jenai tomaka wrote: You can try like this, $row = stored data; and write the options like this option value=id (id == $row ? selected : ) /option Yuri Yarlei.

Re: [PHP] populate form input option dropdown box from existing data

2009-06-16 Thread PJ
Ashley Sheridan wrote: On Tue, 2009-06-16 at 15:48 -0400, PJ wrote: jenai tomaka wrote: You can try like this, $row = stored data; and write the options like this option value=id (id == $row ? selected : ) /option Yuri Yarlei.

Re: [PHP] populate form input option dropdown box from existing data

2009-06-16 Thread Ashley Sheridan
On Tue, 2009-06-16 at 18:19 -0400, PJ wrote: Ashley Sheridan wrote: On Tue, 2009-06-16 at 15:48 -0400, PJ wrote: jenai tomaka wrote: You can try like this, $row = stored data; and write the options like this option value=id (id == $row ? selected : ) /option

Re: [PHP] populate form input option dropdown box from existing data

2009-06-16 Thread PJ
Ashley Sheridan wrote: On Tue, 2009-06-16 at 18:19 -0400, PJ wrote: Ashley Sheridan wrote: On Tue, 2009-06-16 at 15:48 -0400, PJ wrote: jenai tomaka wrote: You can try like this, $row = stored data; and write the options like this option value=id

Re: [PHP] populate form input option dropdown box from existing data

2009-06-16 Thread PJ
Ashley Sheridan wrote: On Tue, 2009-06-16 at 18:19 -0400, PJ wrote: Ashley Sheridan wrote: On Tue, 2009-06-16 at 15:48 -0400, PJ wrote: jenai tomaka wrote: You can try like this, $row = stored data; and write the options like this option value=id

Re: [PHP] populate form input option dropdown box from existing data

2009-06-16 Thread Ashley Sheridan
On Tue, 2009-06-16 at 20:46 -0400, PJ wrote: Ashley Sheridan wrote: On Tue, 2009-06-16 at 18:19 -0400, PJ wrote: Ashley Sheridan wrote: On Tue, 2009-06-16 at 15:48 -0400, PJ wrote: jenai tomaka wrote: You can try like this, $row = stored