代码如下:<?php if ($_GET['action'] == 'add') {
$_re = array();
$_re['member'] = $_POST['member'];
$_re['username'] = $_POST['username'];
$_re['num'] = $_POST['num'];
$_re['pointer'] = $_POST['pointer'];
$_re['all'] = $_POST['all'];
print_r($_re);
}?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
<html xmlns="http://www.w3.org/1999/xhtml">   
<head>   
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />   
<title>TEST</title>    
</head>   
 
<body>
   <form method="post" name="search" action="?action=add">
<table border="1">
<tr><th>学号</th><th>姓名</th><th>数量</th><th>成绩</th><th>选项</th></tr>
<?php 
foreach (range(0,5) as $row) {

?>
 <tr>
  <td><input type="text" name="member[]" value="123456"/></td>
  <td><input type="text" name="username[]" value="小流" /></td>
  <td><input type="text" name="num[]" value="100" /></td>
  <td><input type="text" name="pointer[]" value="50" /></td>
  <td><input type="checkbox" name="all[]" value="<?php echo $row;?>"/></td>
 </tr>
<?php 
   }
?>
<tr><td colspan="4"><input type="submit" name="sub" value="提交" /></td></tr>
</table>
   </form>
</body>   
</html>如代码,点击提交时,input里面的内容全部提交到了$_re[] 数组里面去了~~问题描述: 
1.当我将选择框全部勾选时,print_r($_re);结果如下
其中ALL可接收到如下,其他的member,username等,都接收到了
[all] => Array
        (
            [0] => 0
            [1] => 1
            [2] => 2
            [3] => 3
            [4] => 4
            [5] => 5
        )Array
(
    [member] => Array
        (
            [0] => 123456
            [1] => 123456
            [2] => 123456
            [3] => 123456
            [4] => 123456
            [5] => 123456
        )    [username] => Array
        (
            [0] => 小流
            [1] => 小流
            [2] => 小流
            [3] => 小流
            [4] => 小流
            [5] => 小流
        )    [num] => Array
        (
            [0] => 100
            [1] => 100
            [2] => 100
            [3] => 100
            [4] => 100
            [5] => 100
        )    [pointer] => Array
        (
            [0] => 50
            [1] => 50
            [2] => 50
            [3] => 50
            [4] => 50
            [5] => 50
        )    [all] => Array
        (
            [0] => 0
            [1] => 1
            [2] => 2
            [3] => 3
            [4] => 4
            [5] => 5
        ))2.当我只勾选1,2时 all数组里只有 
[all] => Array
        (
            [0] => 0
            [1] => 1
        )此时能不能让member,username也只显示两项,而不是全部都显示出来,比如
[member] => Array
        (
            [0] => 123456
            [1] => 123456
)
Array
(
    [member] => Array
        (
            [0] => 123456
            [1] => 123456
            [2] => 123456
            [3] => 123456
            [4] => 123456
            [5] => 123456
        )    [username] => Array
        (
            [0] => 小流
            [1] => 小流
            [2] => 小流
            [3] => 小流
            [4] => 小流
            [5] => 小流
        )    [num] => Array
        (
            [0] => 100
            [1] => 100
            [2] => 100
            [3] => 100
            [4] => 100
            [5] => 100
        )    [pointer] => Array
        (
            [0] => 50
            [1] => 50
            [2] => 50
            [3] => 50
            [4] => 50
            [5] => 50
        )    [all] => Array
        (
            [0] => 0
            [1] => 1
        ))
以上,不知道有没有描述清楚,代码可以COPY下来运行看看,谢谢

解决方案 »

  1.   

    怎么过滤啊? 能不能帮忙从上面例子帮忙处理下~~THS~~
      

  2.   


    <?php 
                    foreach (range(0,5) as $row) {
                    
                ?>
                 <tr>
                     <td><input type="text" name="member[<?php echo $row; ?>]" value="123456"/></td>
                     <td><input type="text" name="username[<?php echo $row; ?>]" value="小流" /></td>
                     <td><input type="text" name="num[<?php echo $row; ?>]" value="100" /></td>
                     <td><input type="text" name="pointer[<?php echo $row; ?>]" value="50" /></td>
                     <td><input type="checkbox" name="all[]" value="<?php echo $row;?>"/></td>
                 </tr>
                <?php 
                   }
                ?>
      

  3.   


    <?php 
    if ($_GET['action'] == 'add') {
        $_re = array();
    foreach($_POST['all'] as $row) {
    $_re['member'][] = $_POST['member'][$row];
    $_re['username'][] = $_POST['username'][$row];
    $_re['num'][] = $_POST['num'][$row];
    $_re['pointer'][] = $_POST['pointer'][$row];
    $_re['all'][] = $row;
    }
    echo '<pre>';
        print_r($_re);
    echo '</pre>';}
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
    <html xmlns="http://www.w3.org/1999/xhtml">   
    <head>   
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />   
    <title>TEST</title>    
    </head>   
     
    <body>
       <form method="post" name="search" action="?action=add">
            <table border="1">
                <tr><th>学号</th><th>姓名</th><th>数量</th><th>成绩</th><th>选项</th></tr>
                <?php 
                    foreach (range(0,5) as $row) {
                    
                ?>
                 <tr>
                     <td><input type="text" name="member[<?php echo $row;?>]" value="123456"/></td>
                     <td><input type="text" name="username[<?php echo $row;?>]" value="小流" /></td>
                     <td><input type="text" name="num[<?php echo $row;?>]" value="100" /></td>
                     <td><input type="text" name="pointer[<?php echo $row;?>]" value="50" /></td>
                     <td><input type="checkbox" name="all[<?php echo $row;?>]" value="<?php echo $row;?>"/></td>
                 </tr>
                <?php 
                   }
                ?>
                <tr><td colspan="4"><input type="submit" name="sub" value="提交" /></td></tr>
            </table>
       </form>
    </body>   
    </html>