如何在PHP中使用Oracle数据库(5)
程序员文章站
2022-04-20 09:48:58
利用ora列出全部数据表'email_info'中的数据 下面,我们将逐条读出数据库的内容,并以html表格形式显示'email_info'数据表中的数据 &nb...
利用ora列出全部数据表'email_info'中的数据
下面,我们将逐条读出数据库的内容,并以html表格形式显示'email_info'数据表中的数据
相关php代码:
putenv("oracle_sid=orasid");
$connection = ora_logon ("username","password");
if ($connection == false){
echo ora_errorcode($connection).": ".ora_error($connection)."
";
exit;
}
$cursor = ora_open ($connection);
if ($cursor == false){
echo ora_errorcode($connection).": ".ora_error($connection)."
";
exit;
}
$query = "select * from email_info";
$result = ora_parse ($cursor, $query);
if ($result == false){
echo ora_errorcode($cursor).": ".ora_error($cursor)."
";
exit;
}
$result = ora_exec ($cursor);
if ($result == false){
echo ora_errorcode($cursor).": ".ora_error($cursor)."
";
exit;
}
echo " ";
echo " full name email address
";
while (ora_fetch_into ($cursor, &$values)){
$name = $values[0];
$email = $values[1];
echo " $name $email
";
}
echo " ";
ora_close ($cursor);
ora_logoff ($connection);
?>
程序运行的浏览效果如下所示:
姓名 email 地址
春花 springflower@163.com
秋月 autumnmoon@163.com
... ...
下面,我们将逐条读出数据库的内容,并以html表格形式显示'email_info'数据表中的数据
相关php代码:
putenv("oracle_sid=orasid");
$connection = ora_logon ("username","password");
if ($connection == false){
echo ora_errorcode($connection).": ".ora_error($connection)."
";
exit;
}
$cursor = ora_open ($connection);
if ($cursor == false){
echo ora_errorcode($connection).": ".ora_error($connection)."
";
exit;
}
$query = "select * from email_info";
$result = ora_parse ($cursor, $query);
if ($result == false){
echo ora_errorcode($cursor).": ".ora_error($cursor)."
";
exit;
}
$result = ora_exec ($cursor);
if ($result == false){
echo ora_errorcode($cursor).": ".ora_error($cursor)."
";
exit;
}
echo " ";
echo " full name email address
";
while (ora_fetch_into ($cursor, &$values)){
$name = $values[0];
$email = $values[1];
echo " $name $email
";
}
echo " ";
ora_close ($cursor);
ora_logoff ($connection);
?>
程序运行的浏览效果如下所示:
姓名 email 地址
春花 springflower@163.com
秋月 autumnmoon@163.com
... ...
下一篇: 人大复印资料处理程序_补充篇