Question: I'm having a lot of trouble with storing my values from a database into a dropdown list.
The code doesn't bring any errors, but it just freezes...

**Code**

```
<div class="input-field col-md-12">

          <?php
              echo "<select name='pcID'>";
              $query = "SELECT benutzername FROM benutzer";
              $result = mysql_query($query);
              if(mysql_num_rows($query)>0){
              while($row = mysql_fetch_array($result)){
              echo "<option value=\"owner1\">" . $row['benutzername'] . "
             </option>";
             }
            }
            echo "</select>";
         ?>
        </div>

      </div>

```

I found a lot of other solutions for my problem. But no solution worked for me. It just freezes up (on my loading screen). And as soon as I remove the PHP part it unfreezes...

Does anyone know how I can solve my problem?

**Edit**

yea, like I said. I get no error message in the console at all...

Answer: 
After restructuring my code, I solved it by using the PDO statements.

This is how my solutions looks like now: 

```
<div class="input-field col-md-12">

          <?php
              //query
              $sql = "SELECT benutzername FROM benutzer";
              $statement = $pdo->prepare($sql);
              $statement->execute();
              $users = $statement->fetchAll();

          ?>

          <select>
           <?php foreach ($users as $user): ?>
             <option value="<?= $user['id']; ?>"><?= 
             $user['benutzername'];  ?></option>
           <?php endforeach; ?>
         </select>
        </div>

```
1. You need to connect your db by selecting appropriate database. 

```
$con=mysql_connect("localhost","root","");
mysql_select_db("databasename",$con);

```
2. Your option tag in drop-down list just takes the value and no name to display. I'd suggest you to make minimal changes.

```
echo"<option value=".$row["columnname"].">".$row["column2"]."</option>";

```