Populate html table with data rows. Chooses with select boxes

I’m guessing you ignored the snippet I posted in your other topic. PDO: how to populate html table with rows from database table? - #8 by spaceshiptrooper

Different table, but still the same concept. That whole approach with $sql->setFetchMode(PDO::FETCH_ASSOC); is very numbing. It is appropriate to define a fetch mode in the options when you create your PDO connection. The way you are trying looks to be an old school which has other better ways anyways besides that. You can use setAttribute to set the default fetch mode. That’s a better alternative. However I highly suggest you do it the right way by defining it in the PDO connection.

Another problem I see in your snippet, you are using isset($_POST['predmet'])) which is the same as isset($_POST['submit']) or isset($_POST). This is a rookie move which mostly is taught by websites like w3schools. These are old methods that are basically “hacks” if you will of checking for form submission. The proper way is using $_SERVER['REQUEST_METHOD'].

1 Like