';
echo 'Connected to database
';
echo "Using PDO::FETCH_ASSOC
";
/*** The SQL SELECT statement ***/
//$sql = "SELECT * FROM emp1 ORDER BY fname";
$sql= "SELECT ctof(29.25)";
echo" fetch into an PDOStatement object
";
$stmt = $dbconn->query($sql);
/*** echo number of columns ***/
//$result = $stmt->fetch(PDO::FETCH_NUM);
$result = $stmt->fetch(PDO::FETCH_ASSOC);
// PDO::FETCH_NUM returns the row as a numerical array
/*** loop over the object directly ***/
foreach($result as $key=>$val)
{
echo "function Celsius to Fahrenheit (ºC to ºF) ". $key.' = '.$val.'
';
}
/*** close the database connection ***/
$dbconn= null;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
?>