Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Preencher a lista suspensa dos dados da coluna MySQL

 <select id="teamlist" name="teamlist">
 <?php
        $pdo = new PDO('mysql:host=localhost;dbname=clubresults', 'root', '12345678');
        #Set Error Mode to ERRMODE_EXCEPTION.
        $pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);  

    $stmt = $pdo->prepare('Select teamname from members');
    $stmt->execute();
       while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
    echo '<option>'.$row['teamname'].'</option>';
       }
     ?>
 </select>