return $lijst; } } ?> <!DOCTYPE HTML> <html> <head> <meta charset=utf-8> <title>Databanken introductie</title> </head> <body> <?php $pl = new PersonenLijst(); $tab = $pl->getLijst('Peeters', 'M'); //$tab = $pl->getLijst('Peeters','V'); ?> <ul> <?php foreach ($tab as $naam) { print "<li>" . $naam . "</li>"; } ?> <?php var_dump($tab); ?> </ul> </body> </html>
array_push($lijst, $naam); } $dbh = null; return $lijst; } } ?> <!DOCTYPE HTML> <html> <head> <meta charset=utf-8> <title>Databanken introductie</title> </head> <body> <?php $pl = new PersonenLijst(); $tab = $pl->getLijst(); ?> <ul> <?php foreach ($tab as $naam) { print "<li>" . $naam . "</li>"; } ?> </ul> </body> </html>
<?php //personenlijst.php class PersonenLijst { public function getLijst() { $lijst = array(); $dbh = new PDO("mysql:host=localhost;dbname=cursusphp;charset=utf8", "cursusgebruiker", "cursuspwd"); $dbh = null; } } ?> <!DOCTYPE HTML> <html> <head> <meta charset=utf-8> <title>Databanken introductie</title> </head> <body> <?php $pl = new PersonenLijst(); $pl->getLijst(); ?> </body> </html>