if ($field _value== "") {
echo "<td> </td>";
}
else{
echo "<td> $field _value</td>";
}
}
echo "</tr>";
}
echo "</table>";//Table Output end
Mysql_free_result ($rst) or Die ("Unable to release the result resource!") ");/release result resource
}
else{
echo "There is currently no data in the table!" ";
}
Mysql_close ($server) or Die ("Unable to disconnect from the server!") ");/disconnect and release resources
?>
Open Database Connectivity (ODBC) has become an industry standard for communicating with databases. PHP also provides a standard interface that enables PHP to invoke databases such as Access,sql server. The related functions are:
(1) Integer odbc_connect (string dsn, string user, string password)
Connected to an ODBC database source name.
(2) integer odbc_exec (integer connection, string query) or ODBC_DO (integer connection, string query)
Executes the query on a connection.
(3) Boolean odbc_fetch_row (integer result, integer row)
Gets a row of data from a result set. The row argument is optional and, if it is vacant, returns the next valid row. Returns False when no longer is remaining in the result set.
(4) Boolean odbc_close (integer connection)
Closes a connection to a database. If there is an open transaction on the connection, an error is returned and the connection is not closed.
Finally, look at the pagination example:
?
Set the number of display bars per page
$show _num = 10;
$spages = $pages;//Avoid $pages later changes
Defining connections
$dsn = "localhost";
$user = "sa";
$password = "";
Calculate the total number of records
$rs _num = "SELECT count (*) as ID from BBS where zu= ' 0 ' and lei= '". $lei. "'";
$conn _id = Odbc_connect ($dsn, $user, $password);
$rnum = Odbc_exec ($conn _id, $rs _num);
while (Odbc_fetch_row ($rnum)) {
$total _rs = Odbc_result ($rnum, "id");//Put the total number of records into the $TOTAL_RS variable
}
Count page-related bars
$nnn = total number of pages calculated $total _rs/$show _num;//
$hnnn = Intval ($nnn);//Total number of pages rounded
$cnnnn = $nnn-$hnnn;
Calculate the total number of pages required
Switch ($cnnn) {
Case "0":
$HNNN + +;
$nnn = $hnnn;//Total pages
Break
Default:
$nnn = $hnnn;//Total pages
Break
};
if ($nnn = = 0) $nnn + +;
Calculate the conditions required for page changes
$fore = $pages;
$next = $pages;
$fore-= 1;
$next + 1;
if ($fore > 0) {
echo "<a> home </a>";
echo "<a> front page </a>";
};
if ($pages < $nnn) {
echo "<a> back Page </a>";
echo "<a> last </a>";
};
echo "Altogether", $nnn. " Page ";
$query _string = "SELECT * FROM table where condition order by you wanted order";
$cur = Odbc_exec ($conn _id, $query _string);
Take it to the top of the loop
$cnum = ($pages-1) * $show _num;//calculates the position of the current record cursor
Empty loop to display record cursor
if ($cnum!= 0) {
for ($i =0; $i <= $cnum; Odbc_fetch_row ($cur)) {$i + +;};
};
$i = 1;
Show Records
while (Odbc_fetch_row ($cur)) {
echo;
if ($i = = $show _num) {//Jump out of the program when the number of pages is not satisfied
Break
};
$i + +;
};
Close connection
Odbc_close ($conn _id);
?>
Oracle (Oracle) is the most popular relational database in the world. It is a powerful engine of industrialization promoted by large corporations. Let's take a look at its related functions:
(1) integer ora_logon (string user, string password)
Start a connection to an Oracle database server.
(2) integer ora_open (integer connection)
Opens the cursor for the given connection.
(3) integer ora_do (integer connection, string query)
Executes the query on the given connection. PHP generates an indicator, parses the query, and executes it.
(4) Integer ora_parse (integer cursor, string query)
Resolves a query and is ready to execute.
(5) Boolean ora_exec (integer cursor)
Executes a query that was previously parsed by the Ora_parse function.
(6) Boolean ora_fetch (integer cursor)
This function causes the rows in a executed query to be taken to the indicator. This allows you to call the Ora_getcolumn function.
(7) string ora_getcolumn (integer cursor, integer column)
Returns the current value. The zero-based numeric index of the column.
(8) Boolean ora_logoff (integer connection)
Disconnect the database server.
The following is a sample program for inserting data into an Oracle database:
<body>
<form action= "<?echo $PHP _self;? > "method=" Post >
<table border= "1" cellspacing= "0" cellpadding= "0" >
<tr>
<th>ID</th>
<th>name</th>
<th>Description</th>
</tr>
<tr>
<td><input type= "text" name= "name" Maxlength= "a" size= "ten" ></td>
<td><input type= "text" name= "email" maxlength= "255" size= "></td>"
<td><input type= "text" name= "Description" maxlength= "255" size= "M" ></td>
</tr>
<TR align= "center" >
<TD colspan= "3" ><input type= "Submit" value= "Submission" > <input "reset" type= "rewrite" ></td>
</tr>
</table>
</form>
?
Set two environment variables first ORACLE_HOME,ORACLE_SID
Putenv ("oracle_home=/oracle/app/oracle/product/8.0.4");
Putenv ("Oracle_sid=ora8");
Set up a Web page to display Chinese
Putenv ("nls_lang=simplified_chinese.zhs16cgb231280");
if ($connection =ora_logon ("Scott", "Tiger")) {
Library table test has id,name,description three items
$sql = ' INSERT INTO Test (id,name,description) values ';
$sql. = ' ('. $ID. '','' . $name. '',''. $Description. '')';
if ($cursor =ora_do ($connect, $sql)) {