需要使用PHP从MySQL数据库中提取数据来读取动态复选框

时间:2014-01-29 03:08:48

标签: php mysql checkbox dynamic html-table

我正在尝试使用先前创建的动态复选框从mysql表中提取数据,但是看起来我的搜索只显示最多2条记录,如果我选择了3个以上的复选框,它将不会返回任何内容,所以我想知道是否有人可以帮我弄清楚怎么做。

以下是我的代码,非常感谢您的帮助:

$warehouse = @$_POST['wh'];
switch($button){
    case 'Submit':
    if(@$_POST['wh']){
    $warehouse = @$_POST['wh'];
    $length = count($warehouse);
    for ($i = 0; $i < $length; $i++){
    //echo '<br>'.$warehouse[$i];


                }                           

                $consult = "SELECT * FROM contact_info WHERE ";
                for ($i = 0; $i < $length; $i++){
                    $consult = $consult . "warehouse='$warehouse[$i]'";
                    if(!$i+1 == $length){
                        $consult = $consult . " OR ";
                    }

                }
                echo '<br>'.$length.'<br>';
                print_r ($consult);
                $response = mysqli_query($connection, $consult);
            if($response){
                    $registry = mysqli_affected_rows($connection);

            if($registry > 1){                      
                    echo '<br><table width="800" align="center" border="2" cellspacing="1" cellpadding="1">
                            <form action="index.php" method="post" >
                                <tr>
                                    <td align="center"><strong>Warehouse</strong></td>
                                    <td align="center"><strong>Name</strong></td>
                                    <td align="center"><strong>Lastname</strong></td>
                                    <td align="center"><strong>Phone</strong></td>
                                    <td align="center"><strong>I-net</strong></td>
                                    <td align="center"><strong>E-mail</strong></td>
                                </tr>';

                while($registry = mysqli_fetch_array($response, MYSQLI_ASSOC)){
                    echo '<form action="index.php" method=post >    
                            <tr>
                                <td div align="center">'.$registry['warehouse'].'
                                <td div align="center">'.$registry['name'].'
                                <td div align="center">'.$registry['lastname'].'
                                <td div align="center">'.$registry['phone'].'
                                <td div align="center">'.$registry['inet'].'
                                <td div align="center">'.$registry['email'].'
                            </tr>';


                                        }
                                        echo '</form>';
                                    echo '
                                    </form>
                            </table>';

0 个答案:

没有答案