Question by samuel101: Can anybody help me with this PHP code?
I create a html which you can select your hobbies and using form method GET, the php code will show the selected hobbies. My problem is im confused with my PHP code Here’s my Code:


What are your hobbies:

Eating Programming
Sleeping Reading
Texting Graphics Design



My PHP code:

‘;

foreach ($ hobbies as $ h)
{
if($ h==’checked’)
echo $ _GET[$ h];
}

?>

thanks for your help!
im the process learning the GET function! but thanks for your ideas! =p

Best answer:

Answer by Jeff P
Try this:

$ hobbies = $ _REQUEST[‘hobbies’];

echo “Your hobbies are:
“;

if(count($ hobbies) > 0) {
for($ i =0; $ i < count($ hobbies); $ i++) { echo $ hobbies[$ i]; } }

Give your answer to this question below!

One thought on “Can anybody help me with this PHP code?”

  1. Checkboxes don’t work that way!

    Here it is:






    ";
    $ status = "Your marital status is ".$ _POST['statv']."
    ";
    echo ($ lang."
    ".$ status);
    }
    else
    {
    ?>

    The languages you speak:
    English

    French

    German

    Portuguese

    Your marital status:
    Batchelor
    Married
    Divorced
    Widower




Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.