PhP选择不发送值

时间:2015-06-04 14:17:44

标签: php sql forms select fetch

                <?php

                    include ("forms/coneccao_feed.php");
                        $query = "SELECT id as ID, nome as Nome FROM provedor";
                        $query1= "Select MAX(id) as ID From provedor";
                        $ultprovedor = mysqli_query ($ligacao_feed, $query1);
                        $ultimo_provedor = mysqli_fetch_row($ultprovedor);
                        $provedores = mysqli_query($ligacao_feed, $query);
                        ?>
                            <select name="provedor">
                            <?php
                                while($provedor=mysqli_fetch_array($provedores)){                               
                                    if ($provedor['ID'] == $ultimo_provedor['0']){                              
                                    ?>
                                        <option value="<?php echo $provedor['ID']; ?>" selected><?php echo $provedor['Nome'] ?></option>
                                        <?php
                                                }else{                              
                                                ?>
                                        <option value="<?php echo $provedor['ID']; ?>"><?php echo $provedor['Nome'] ?></option>
                                        <?php
                                                }
                                }?>
                            </select>   

我搜索到了所有地方,但无法找到答案,当我提交时它没有发送任何东西,我试图在表格中回声,但它也什么也没做。

        <?php
            include ("forms/coneccao_feed.php");
            $id_provedor = $_POST['id'];
            $mensagem = $_POST['msg'];
            $query = "Select nome as Nome From provedor where id='".$id_provedor."'";
            echo $query;
            echo "<br>".$mensagem."<br>".$id_provedor;
            //$res_query = ($ligacao_feed, $query);

        ?>

1 个答案:

答案 0 :(得分:2)

您的select nameprovedor,但您在id作业中使用$_POST

$id_provedor = $_POST['id'];

应该是

$id_provedor = $_POST['provedor'];