<? PHP
$ Conn = ocilogon ("username", "password", "(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 statement
$ 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 );
?>
Method 2:
CopyCode The Code is as follows: <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 );
}
?>
Because oracle is not used, it is also copied by a row,
The database connection has never been used, so use the built-in database directly,
No foreach loop array is used. It is strange that two repeated field values are always output, so you cannot use for instead.
QQ: 57112848 Anonymous