Reply to Re: mysql update and checkboxes

Your name:

Reply:


Posted by IchBin on 06/25/06 01:37

frizzle wrote:
> Hi there,
>
> I'm building a music site with a mysql backend. It has a many to many
> relational database.
> I use this to match music genres with certain artists, to maintain the
> possibility to add multiple genres to a singe artist.
>
> Now i've searched google, but can't find a solution on how to update
> rows with checkboxes.
> If an artist gets his genre updated as follows:
> from
>
> - [_] classic
> - [X] rock
> - [_] ballad
> - [X] 80's
> - [_] 90's
> - etc.
>
> to
>
> - [_] classic
> - [_] rock
> - [_] ballad
> - [_] 80's
> - [X] 90's
> etc.
>
> wha t i wonder is how could i best create the backend. it would seem
> inappropraite to run an update query for each possible box wether it's
> checked or not.
>
> frizzle.
>
In the old days, in system programing, you would maintain one byte using
bit masking and you could set multiple bit setting by the sum of their
values.

Translating this... you could have say one int bucket column that can be
set to all or combinations of selections. You would have only one column
to check You would know what the values are by the total added together.

[X] classic = 1
[X] rock = 2
[_] ballad = 4
[_] 80's = 8
[X] 90's = 13

Example, above the bucket value would be 16

if you had 6 the you know it is 'rock' and 'ballad'
if you had 10 the you know it is 'rock' and '80's'
.... and so on.....

You just need a function to physically set you GUI based on the size of
the bucket. You will not have to check on an update..

So when it is time yo update you do not have to worry about updating
multiple columns. You just sum up the values and save that.

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.awardspace.com
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация