-- Learning technology, pursuing dreams!
Home HTML JAVASCRIPT CSS VUE REACT PYTHON3 JAVA C C++ C# AI GO SQL LINUX VS CODE BOOTSTRAP GIT Local Bookmarks
PHP Tutorial
PHP Tutorial
PHP Introduction
PHP Installation
PHP Syntax
PHP Variables
PHP echo/print
PHP EOF(heredoc)
PHP Data Types
PHP Type Comparison
PHP Constants
PHP Strings
PHP Operators
PHP If...Else
PHP Switch
PHP Arrays
PHP Array Sorting
PHP Superglobals
PHP While Loop
PHP For Loop
PHP Functions
PHP Magic Constants
PHP Namespaces
PHP Object-Oriented
PHP Quiz
PHP Forms
PHP Forms
PHP Form Validation
PHP Form - Required Fields
PHP Form - Validate Email and URL
PHP Complete Form Example
PHP $_GET Variable
PHP $_POST Variable
PHP Advanced Tutorial
PHP Multidimensional Arrays
PHP Date
PHP Include
PHP File
PHP File Upload
PHP Cookie
PHP Session
PHP E-mail
PHP Secure E-mail
PHP Error
PHP Exception
PHP Filter
PHP Advanced Filter
PHP JSON
PHP 7 New Features
PHP 7 New Features
PHP Database
PHP MySQL Introduction
PHP MySQL Connection
PHP MySQL Create Database
PHP MySQL Create Data Table
PHP MySQL Insert Data
PHP MySQL Insert Multiple Data
PHP MySQL Prepared Statements
PHP MySQL Read Data
PHP MySQL Where
PHP MySQL Order By
PHP MySQL Update
PHP MySQL Delete
PHP ODBC
PHP XML
XML Expat Parser
XML DOM
XML SimpleXML
PHP and AJAX
AJAX Introduction
AJAX PHP
AJAX Database
AJAX XML
AJAX Real-time Search
AJAX RSS Reader
AJAX Vote
PHP Reference Manual
PHP Array
PHP Calendar
PHP cURL
PHP Date
PHP Directory
PHP Error
PHP Filesystem
PHP Filter
PHP FTP
PHP HTTP
PHP Libxml
PHP Mail
PHP Math
PHP Misc
PHP MySQLi
PHP PDO
PHP SimpleXML
PHP String
PHP XML
PHP Zip
PHP Timezones
PHP Image Processing
PHP RESTful
PHP PCRE
PHP Available Functions
PHP Composer
PHP MySQL Delete
PHP XML Expat Parser
PHP Database ODBC
ODBC is an Application Programming Interface (API) that enables us to connect to a data source (such as an MS Access database).
Create ODBC Connection
Through an ODBC connection, you can connect to any database on any computer in your network, as long as the ODBC connection is available.
Here is how to create an ODBC connection to an MS Access database:
Open the Administrative Tools icon in Control Panel.
Double-click the Data Sources (ODBC) icon.
Select the System DSN tab.
Click Add in the System DSN tab.
Select Microsoft Access Driver. Click Finish.
In the next interface, click Select to locate the database.
Give the database a Data Source Name (DSN).
Click OK.
Please note that this configuration must be completed on the computer where your website is located. If Internet Information Services (IIS) is running on your computer, the above instructions will work, but if your website is on a remote server, you must have physical access to that server, or ask your hosting provider to create the DSN for you.
Connect to ODBC
The odbc_connect() function is used to connect to an ODBC data source. This function has four parameters: data source name, username, password, and an optional cursor type.
The odbc_exec() function is used to execute SQL statements.
Example
The following example creates a connection to a DSN named northwind, with no username and password. Then creates and executes an SQL statement:
$conn=odbc_connect('northwind','','');
$sql="SELECT * FROM customers";
$rs=odbc_exec($conn,$sql);
Retrieve Records
The odbc_fetch_row() function is used to return records from a result set. If a row can be returned, the function returns true, otherwise it returns false.
This function has two parameters: ODBC result identifier and an optional row number:
odbc_fetch_row($rs)
Retrieve Fields from Records
The odbc_result() function is used to read fields from records. This function has two parameters: ODBC result identifier and field number or name.
The following code line returns the value of the first field from the record:
$compname=odbc_result($rs,1);
The following code line returns the value of the field named "CompanyName":
$compname=odbc_result($rs,"CompanyName");
Close ODBC Connection
The odbc_close() function is used to close an ODBC connection.
odbc_close($conn);
ODBC Example
The following example demonstrates how to first create a database connection, then create a result set, and then display data in an HTML table.
<?php
$conn=odbc_connect('northwind','','');
if (!$conn)
{
exit("Connection Failed: " . $conn);
}
$sql="SELECT * FROM customers";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{
exit("SQL Statement Error");
}
echo "
";
echo "| Companyname | ";
echo "Contactname |
";
while (odbc_fetch_row($rs))
{
$compname=odbc_result($rs,"CompanyName");
$conname=odbc_result($rs,"ContactName");
echo "| $compname | ";
echo "$conname |
";
}
odbc_close($conn);
echo "
";
?>
PHP MySQL Delete
PHP XML Expat Parser
ByteArk Coding Plan
Supports mainstream large models such as Doubao, GLM, DeepSeek, Kimi, MiniMax, official direct supply stable and reliable.
¥9.9
/ month
Activate now
iFLYTEK Starry Sky Coding Plan
Includes free model call quotas, DeepSeek, GLM, Kimi, MiniMax, one-stop experience and deployment platform.
¥3.9
/ month
Activate now
Click to Share Notes
Category Navigation
Python / Data Science
AI / Intelligent Development
Frontend Development
Backend Development
Database
Mobile Development
DevOps / Engineering
Programming Languages
Computer Basics
XML / Web Service
.NET
Website Building
Advertisement
PHP Tutorial
PHP Tutorial
PHP Introduction
PHP Installation
PHP Syntax
PHP Variables
PHP echo/print
PHP EOF(heredoc)
PHP Data Types
PHP Type Comparison
PHP Constants
PHP Strings
PHP Operators
PHP If...Else
PHP Switch
PHP Arrays
PHP Array Sorting
PHP Superglobals
PHP While Loop
PHP For Loop
PHP Functions
PHP Magic Constants
PHP Namespaces
PHP Object-Oriented
PHP Quiz
PHP Forms
PHP Forms
PHP Form Validation
PHP Form - Required Fields
PHP Form - Validate Email and URL
PHP Complete Form Example
PHP $_GET Variable
PHP $_POST Variable
PHP Advanced Tutorial
PHP Multidimensional Arrays
PHP Date
PHP Include
PHP File
PHP File Upload
PHP Cookie
PHP Session
PHP E-mail
PHP Secure E-mail
PHP Error
PHP Exception
PHP Filter
PHP Advanced Filter
PHP JSON
PHP 7 New Features
PHP 7 New Features
PHP Database
PHP MySQL Introduction
PHP MySQL Connection
PHP MySQL Create Database
PHP MySQL Create Data Table
PHP MySQL Insert Data
PHP MySQL Insert Multiple Data
PHP MySQL Prepared Statements
PHP MySQL Read Data
PHP MySQL Where
PHP MySQL Order By
PHP MySQL Update
PHP MySQL Delete
PHP ODBC
PHP XML
XML Expat Parser
XML DOM
XML SimpleXML
PHP and AJAX
AJAX Introduction
AJAX PHP
AJAX Database
AJAX XML
AJAX Real-time Search
AJAX RSS Reader
AJAX Vote
PHP Reference Manual
PHP Array
PHP Calendar
PHP cURL
PHP Date
PHP Directory
PHP Error
PHP Filesystem
PHP Filter
PHP FTP
PHP HTTP
PHP Libxml
PHP Mail
PHP Math
PHP Misc
PHP MySQLi
PHP PDO
PHP SimpleXML
PHP String
PHP XML
PHP Zip
PHP Timezones
PHP Image Processing
PHP RESTful
PHP PCRE
PHP Available Functions
PHP Composer
Online Examples
·HTML Examples
·CSS Examples
·JavaScript Examples
·Ajax Examples
·jQuery Examples
·XML Examples
·Java Examples
Character Set & Tools
· HTML Character Set Settings
· HTML ASCII Character Set
· JS Obfuscation/Encryption
· PNG/JPEG Image Compression
· HTML Color Picker
· JSON Formatting Tool
· Random Number Generator
Latest Updates
· Dart Enums and Symbols
· Dart Unit Testing
· Dart Concurrency and Iso...
· Dart Stream Flow
· Dart Asynchronous Programming
· Dart typedef and...
· Dart Package and Library Management
Site Information
· Feedback
· Disclaimer
· About Us
· Article Archives
Follow WeChat
My Favorites
Mark Article
Browse History
Clear All
No Records