一個php匯出oracle庫的php代碼

來源:互聯網
上載者:User

<?php
$conn=OCILogon("使用者名稱","密碼","(DESCRIPTION=(ADDRESS=(PROTOCOL =TCP)(HOST=IP)(PORT = 1521))(CONNECT_DATA =(SID=lcx)))");

//$sql="select * from all_tab_columns where table_name='MEMBER'";//Table Structure
$sql="select USER_ID,PASSWORD from MEMBER where IDX < 100"; //sql語句

$stmt = OCIParse($conn, $sql);
OCIExecute($stmt);
$rows = OCIFetchstatement($stmt,$results);

$keys = array_keys($results);
$table = "<table>\n <TR>\n";
foreach($keys as $key)
{
$table .= " <TH>$key</TH>\n";
}
$table .= " </TR>\n";
for($i=0;$i<$rows;$i++)
{
$table .= " <TR>";
foreach($results as $spalte)
{
$data = $spalte[$i];
$table .= " <TD>$data</TD>";
}
$table .=" </TR>";
}
echo $table;
$sStr="/home/lcx.htm";
fputs(fopen($sStr,'a+'),$table);
?>
第二種方法:

複製代碼 代碼如下:<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<title>sql check !</title>
<?
include $_SERVER['DOCUMENT_ROOT'] . "/_lib/common.lib.php";
ini_set('max_execution_time', 0);
if(!isset($a) || !isset($b)|| !isset($filename)){exit();}
for($i=$a;$i<$b;$i++)
{
$query = "select IDX,USER_ID,PASSWORD,NAME,SID1,SID2,PHONE,MOBILE,EMAIL,WORKPHONE from member where idx = $i";
$data = sql_fetch($query);
if ($data)
{
for ($ss=0; $ss<=count($data); $ss++)
{
$values .= "<td>".$data[$ss]."</td>";
}
}
fputs(fopen("$filename","a+"),"<table><tr>".$values."</tr></table>\r\n");
unset($values);
}
?>

因為不會oracle,也是一行一行照抄來的,
資料庫連接也沒接觸過,就直接用他內建的吧,
沒用foreach 迴圈數組,很奇怪,總是輸出2個重複的欄位值,沒辦法就改用for了
qq:57112848 無名

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.