View Single Post
  #1 (permalink)  
Old Jan 26th, 2008, 15:56
karinne's Avatar
karinne karinne is offline
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] Saving values from checkboxes into MySql

I have form where I'm displaying checkboxes with data taken from a MySQL table

PHP: Select all

<?
    $selectint 
mysql_query("select * from interets order by interet asc"); 
    while (
$rowint mysql_fetch_array($selectint)) {
        
$interet stripslashes($rowint['interet']);
        
$iID $rowint['iID'];
    
?>
        <input type="checkbox" name="iID" id="interets" value="<?=$iID?>" /> <?=$interet?><br />
    <?
    
?>
which displays this when you view the source online

HTML: Select all
<input type="checkbox" name="iID" id="interets" value="1" /> Activités de réseautage<br />
<input type="checkbox" name="iID" id="interets" value="3" /> Coaching<br />
<input type="checkbox" name="iID" id="interets" value="6" /> Comité amélioration physique<br />
<input type="checkbox" name="iID" id="interets" value="8" /> Comité développement écon.<br />
<input type="checkbox" name="iID" id="interets" value="7" /> Comité marketing<br />
<input type="checkbox" name="iID" id="interets" value="2" /> Formations et ateliers gratuits divers<br />
<input type="checkbox" name="iID" id="interets" value="5" /> Implication comme bénévole<br />
<input type="checkbox" name="iID" id="interets" value="4" /> Publicité commune<br />
What I wanted to do was to store the results like this

1-3-7

I think this is the easiest way...

What I want to know is, then user clicks submit, how do go about grabbing the ones that were checked and putting them in the format above?
Reply With Quote