Thursday, March 03, 2005

Using pear DB class

// Load the DB code
require 'DB.php';

// Connect to the database
$dbh = DB::connect('mysql://ipms:nopass@localhost/ipms');

// Send a SELECT query to the database
$sth = $dbh->query('SELECT * FROM IPMS_LEAVE');

// Check if any rows were returned
if ($sth->numRows()) {
print "";
print "";
// Retrieve each row
while ($row = $sth->fetchRow()) {
// And print out the elements in the row
print
"\n";
}
print "
IDLeave DateNotify Date
$row[0]$row[1]$row[2]
";
} else {
print "No results";
}

?>

No comments: