hi im attempting to add a multiple checkbox with a few options see html code

<form method="post">
<table width="900">
  <tbody>
    <tr>
      <td width="900"><input name="interests[]" id="option1" value="option1" type="checkbox">option1</td>
      <td width="900"><input name="interests[]" id="option2" value="option2" type="checkbox">option2</td>
      <td width="900"><input name="interests[]" id="option3" value="option3" type="checkbox">option3</td>
    </tr>
    <tr>
    <td><input name="interests[]" id="option4" value="option4" type="checkbox">option4</td>
    <td><input name="interests[]" id="option5" value="option5" type="checkbox">option5</td>
    <td><input name="interests[]" id="option6" value="option6" type="checkbox">option6</td>
    </tr>
    </table>
    <input type="submit" value="Show my Items" name="save"/>        

and heres the php

<?php

extract($_POST);

if(isset($save))

{

if(!empty($interests))

{

echo "<h3>You have selected these items :</h3>";

echo "<ol type='A'>";

foreach($interests as $val)

{

echo "<li>";

echo $val;

echo "</li>";

}

echo "</ol>";

}

else

{

echo "<font color='red'>pls select your items</font>";

}

}

?>

but when i click submit all i get is

You have selected these items :
A
B
C
D
Any ideals of what need doing to show values any help would be much appreicated

Recommended Answers

All 3 Replies

Use var_dump($val); instead of echo $val; to see what is returned. If the form ends like this (with a </form>) and there aren't other input fields, then it should work fine.

Also you could do echo "<pre>". print_r($_POST, true) . "</pre>"; to see what is sent to the $_POST array.

solved that one forgot to put the values in lol

it happens... lol :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.