获取两个动态下拉列表的值

时间:2019-01-16 21:37:56

标签: php html

因此,我具有用于生成两个以下动态下拉列表的代码:

<body>
        <div class="container">
        <h1><center>Equipe</center></h1>    

        <FORM METHOD="POST">
            <table>
                <thead> <!-- En-tête du tableau -->
                    <tr>
                        <th>
                            <select name="ListeEquipe1" id="ListeEquipe1"><br/>
                                <option value="" slected="selected"></option>
                                <?php
                                 $resultat = $bdd->query('SELECT distinct Equipe1 FROM equipe Order by Equipe1 ASC') or die (print_r($bdd->errorInfo()));
                                    while ($donnees = $resultat->fetch())
                                    {
                                        echo '<option value="' . $donnees['Equipe1'] . '">' . $donnees['Equipe1'] .  '</option>';
                                    }
                                    $resultat->closeCursor();?>
                            </select>
                        </th>
                        <th>
                            <select name="ListeEquipe2" id="ListeEquipe2"><br/> 
                                <option value="" slected="selected"></option>
                                <?php
                                 $resultat = $bdd->query('SELECT distinct Equipe2 FROM equipe Order by Equipe2 ASC') or die (print_r($bdd->errorInfo()));;
                                    while ($donnees = $resultat->fetch())
                                    {
                                        echo '<option value="' . $donnees['Equipe2'] . '">' . $donnees['Equipe2'] .  '</option>';
                                    }
                                    $resultat->closeCursor();?>
                            </select>
                        </th>
                    </tr>
                    <tr>
                        <th>%Equipe 1</th>
                        <th>%Equipe 2</th>
                    </tr>
                </thead>

然后我需要获取两个列表的选定值,然后在单击时显示同一数据库中的值,目前我正在使用该值,两个请求必须获得两个选定值: / p>

<tbody>
                    <tr><!-- Corps du tableau -->
                    <?php
                            $resultat = $bdd->query('SELECT PEquipe1 FROM equipe Where Equipe1 LIKE "test1e1"') or die (print_r($bdd->errorInfo()));
                                    while ($donnees = $resultat->fetch())
                                    {
                                        ?><td><?php echo $donnees['PEquipe1'];?></td><?php
                                    }
                                    $resultat->closeCursor();?>
                    <?php
                            $resultat = $bdd->query('SELECT  PEquipe2 FROM equipe Where Equipe2 Like "test1e2"') or die (print_r($bdd->errorInfo()));
                                    while ($donnees = $resultat->fetch())
                                        {
                                            ?><td><?php echo $donnees['PEquipe2'];?></td><?php
                                        }
                                            $resultat->closeCursor();?>
                    </tr> 
                    <tr>
                        <th>Equipe 1</th>
                        <th>Equipe 2</th>                        
                    </tr>
                 </tbody>
            </table>
            <div>
            <INPUT src="94.jpg" class="btns" onclick="ListeEquipe1;" type="submit" value="Calcul" href=""/>
        </div>
        </FORM>

我只需要使用html和PHP。 那可能吗 ? 因为当我尝试使用ID时,我有一个未定义的索引。

0 个答案:

没有答案