Re: Displaying checkbox values selected

From: Date: Fri, 17 May 2002 15:36:41 +0000
Subject: Re: Displaying checkbox values selected
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-13837@lists.php.net to get a copy of this message
"C Sims" <calebsim@optushome.com.au> wrote in message news:20020517145527.16225.qmail@pb1.pair.com... > Hi all, > would appreciate any help with this (newbie) question. All im trying to do > is to echo on screen the checkbox values selected by the user. Problem is > when submit is pressed, the selected artists dont appear, it just goes back > to the original screen (with empty checkboxes). <?php // ideally, you would read these values from a database $artists = array("Bon Jovi", "N'Sync", "Boyzone", "Britney Spears"); echo "\n<form action='$PHP_SELF' method='post'>"; foreach($artists as $a) echo "\n\t<input type='checkbox' name='artist[]' value='$a'" .(in_array($a, $artist) ? " checked" : "") .">$a</input>"; echo "<br />" ."\n\t<input type='submit' name='submit' value='Select'>" ."\n</form>"; if(isset($submit)) { echo "<b>And here are your selections:</b><br />"; foreach($artist as $a) echo "<i>$a</i><br />"; } ?>

« previous php.windows (#13837) next »