0

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

2
Contributors
3
Replies
20
Views
1 Year
Discussion Span
Last Post by cereal
0

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.

Edited by cereal

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.