1

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>";
    }
3
  • Did you check if you have right column names in array? Commented Apr 5, 2014 at 10:41
  • Also turn on error reporting in php or web server to see where is the problem Commented Apr 5, 2014 at 10:44
  • Yes, i did, though it still is blank Commented Apr 5, 2014 at 10:56

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

12 Comments

Check the HTML source if there is any option or error message?
so where does it stop? do you see the </select>? Is there anything in the table at all? Are the field names correct? Try a print_r($row); in the loop.
Yes. But if there is no data it cannot display anything.You only showed the table layout
there is data, 4 Types of contact.
Sorry, to clarify: when you look at the page and use the View Document Source function of your browser. You need to look at the output of PHP that you get via HTTP
|
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.