user3478311
user3478311

Reputation: 33

PHP Combobox from MySQL

I'm doing my homework and we're supposed to do registration, and i'm stuck at combobox, it does show something but it shows a blank , we're prohibited to use mysql_query, and any other object than PDO.

$query = "SELECT * FROM tbltypkon";
    $result = $db->query($query);
    while($row=mysql_fetch_array($result, MYSQL_ASSOC)){                                                 
       echo "<option value='".$row['ID_TYPKON']."'>".$row['TYPKONTAKTU']."</option>";
    }

Upvotes: 1

Views: 197

Answers (2)

akirk
akirk

Reputation: 6857

You need to define the $db variable, i.e. connect to the database

Upvotes: 1

akirk
akirk

Reputation: 6857

Instead of

$row = mysql_fetch_array($result, MYSQL_ASSOC)

you should use

$row = $result->fetch(PDO::FETCH_ASSOC)

see PDOStatement::fetch in the PHP Manual.

Upvotes: 1

Related Questions