Re: Re: <input type="checkbox">

From: Date: Sat, 15 Mar 2008 05:55:36 +0000
Subject: Re: Re: <input type="checkbox">
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.general 
Request: Send a blank email to php-general+get-271645@lists.php.net to get a copy of this message
On Sat, 2008-03-15 at 01:00 -0400, John Taylor-Johnston wrote: > Robert Cummings wrote: > > On Sat, 2008-03-15 at 00:33 -0400, John Taylor-Johnston wrote: > >> Robert, > >> > >>>>>> Array > >>>>>> ( > >>>>>> [0] => Hemmingford > >>>>>> [1] => Huntingdon > >>>>>> ) > >>> You want the following (otherwise each checked entry overwrites the > >>> previous): > >>> <input type="checkbox" name="checkregion[]" > >>> value="Knowlton" /> > >>> <input type="checkbox" name="checkregion[]" > >>> value="Thetford Mines" /> > >> How would you proceed? > >> > >> $sql ='insert into > >> database.table > >> (Nom ,checkregion) > >> values ('John', '". ?? ."') '; > >> > >> I'm just guessing. > > > > It depend son what you want to do with the data. It may be that you want > > a row for every selected entry or it may be that you can just serialize > > the data. Do you want to just have a snapshot of what the user chose? Or > > do you want to be able to query the database about who selected > > "Knowlton"? If the former, then you can get away with just serializing > > the data, but if you want to be able to do queries, then you need to > > store each entry in its own row. > > > > Cheers, > > Rob. > > It would look like: > > $sql ='insert into database.Y¥Œˆgn�w E > 7Âî7table (Nom > ,checkregion) > values ('John', 'Montreal,Knowlton,anything') '; > > checkregion[5] = "Montreal"; > checkregion[7] = "Knowlton"; > checkregion[55] = "anything"; > > I need to unarray checkregion[] and break it up into separate words and > then separate them by commas. $regions = implode( ',', $checkregion ); $sql = "INSERT INTO database.table " ."( " ." Nom, " ." checkregion " .") " ."VALUES " ."( " ." '".mysql_real_escape_string( $nom, $conn )."', " ." '".mysql_real_escape_string( $regions, $conn )."' " .") "; Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP

« previous php.general (#271645) next »