Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Dropdown-Liste aus MySQL-Spaltendaten füllen

 <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>