SHOW:
|
|
- or go back to the newest paste.
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
2 | <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
3 | <body> | |
4 | <?php | |
5 | try{ | |
6 | // Connect | |
7 | $dbh = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=C:\\xampp\\htdocs\\bd\\db\\icr.accdb;Uid=Admin"); | |
8 | $dbh->exec("set names utf8"); | |
9 | $sql = "SELECT * FROM Miasta"; | |
10 | $myFile = "testFile.txt"; | |
11 | $fh = fopen($myFile, 'w') or die("can't open file"); | |
12 | foreach ($dbh->query($sql) as $row) | |
13 | { | |
14 | - | echo $row['Nazwa'] .' - '. $row['IDWojewodztwa'] . '<br />'; |
14 | + | echo $row['Nazwa'] .' - '. $row['IDWojewództwa'] . '<br />'; |
15 | $stringData = $row['Nazwa'] .' - '. $row['IDWojewództwa'] . '<br />'; | |
16 | fwrite($fh, $stringData); | |
17 | } | |
18 | fclose($fh); | |
19 | /*** close the database connection ***/ | |
20 | $dbh = null; | |
21 | } | |
22 | catch(PDOException $e) | |
23 | { | |
24 | echo $e->getMessage(); | |
25 | } | |
26 | ?> | |
27 | </body> | |
28 | </html> |