Showing posts with label PDO. Show all posts
Showing posts with label PDO. Show all posts

Sunday, October 4, 2009

MySQL and PDO

This will display all of the links and descriptions

//change these
$user = 'root';
$pass = '';
try
{
//localhost, test database
$dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass);
//table is called test
foreach($dbh->query('SELECT * from test') as $row)
{
print "{$row['name']} : {$row['desc']}
";
}
$dbh = null;
}
catch (PDOException $e)
{ print "Error!: " . $e->getMessage() . "
";
die();
}
?>