"C Sims" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> 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 />";
}

?>



-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to