
Untitled
By: a guest on
Dec 9th, 2012 | syntax:
PHP | size: 0.92 KB | hits: 32 | expires: Never
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<body>
<?php
try{
// Connect
$dbh = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=C:\\xampp\\htdocs\\bd\\db\\icr.accdb;Uid=Admin");
$dbh->exec("set names utf8");
$sql = "SELECT * FROM Miasta";
$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
foreach ($dbh->query($sql) as $row)
{
echo $row['Nazwa'] .' - '. $row['IDWojewództwa'] . '<br />';
$stringData = $row['Nazwa'] .' - '. $row['IDWojewództwa'] . '<br />';
fwrite($fh, $stringData);
}
fclose($fh);
/*** close the database connection ***/
$dbh = null;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
?>
</body>
</html>