0

在使用方括号符号之前,我已经将元素组合在一起,但我必须忽略一些东西。也许另一双(或数千)眼睛可以发现为什么会适得其反。

foreach ( $record as $field => $value) {

if(strpos($value , '~') !== FALSE){ //All drop down lists are separated by ~
    $rows_of_dlist .= '<tr>';

$stored_field = explode ( "mlljx", $value );
$stored_field [0] = trim ( $stored_field [0] ); //Title of the list
$stored_field [1] = trim ( $stored_field [1] ); //Values of the list


$dlist = explode ( '~', $stored_field [1] );

foreach ( $dlist as $dlist ) {
    $list_values .= " <td><input type='checkbox' name='selected_option[]'value='$dlist'/> &nbsp; $dlist</td>";
}

$rows_of_dlist .= "<td align = 'center'>$stored_field[0]</td> $list_values</tr>";


<form id="all" name="all" method="POST" action="$page_name?page_view=report" >
    <table align="center" width = "100%" border = "2">  
        <th colspan = "1">Name Of Custom Drop-down List</th>
        <th colspan = "10">Drop-list Values</th>
        $rows_of_dlist      
        <tr>
            <td align = 'center' colspan='10'>
                        <input type="submit" value="Make PDF" name = "make_pdf"/>
            </td>
        </tr>
    </table>
</form>

发布值后,我测试 POST 数组:

  var_dump($_POST);
  exit;

然后它说$_POST['selected_option']是“数组”,即使我只选择一个框。

4

1 回答 1

1

我认为这是错误的:

foreach ( $dlist as $dlist ) {

不应该是这样的

foreach ( $dlist as $element) { ... do something with each $element ... }
于 2012-11-15T16:48:29.710 回答