- Home
- Registration
- Database Design
- Password Keeper
- MySQL and Excel
- Learn MySQL
- Learn SQL
- Learn C++
- Learn Java
- Learn Visual Basic
- Web Site Tips
- Miscellaneous
- Affordable Hosting
- PHP Code Examples
- Learn PHP
- Virtual Server
- Apache:OS 10048
- PHP Class Example
- Page View Counter
- Display Any Table
- Read csv file
- PHP Array Functions
- Array of Fields
- PHP and MS Access
- Authentication
- PHP App Example
- Display Image PHP
- Image Collection
- Block Spam Post
- Upload File PHP
- $_REQUEST,$_SESSION
- Site map
- Advertise here
- LaptopForLess
- Geeks´ Stuff
- Nerds´ Stuff
- Remote Control Toys
How to connect to MS Access. PHP and ODBC
By Sergey Skudaev
![]()
![]()
![]()
![]()
![]()
![]()
In this tutorial I give you PHP code example connection to MS Access database. It is easy if you run Web Server on Widows PC. For Unix special driver is required. This tutorial teaches you how to connect to MS Access on Windows PC. Also, you will learn how to write SQL query to insert data to MS Access database or to select data from MS Access database.
CSS layout for PC and mobile device. $2.95
By S.Skudaev, (an eBay Excellent seller)
Contents:
1. How to install Pocket PC emulator on your Windows PC
2. Three columns layout CSS styles for regular PC browsers
3. One column layout CSS styles for mobile device

Pay via PayPal. You should not be concern about my web site security, because when you click the link, you will be redirected to PayPal site and it can be trusted. You will have your financial transaction with PayPal, not with me. So, please do not afraid to buy from my site. Credit cards are accepted. After payment is done, on the PayPal thank you page
Three columns layout template created in such a way that the middle column content coming first in the HTML code. This way, Google spider, while visiting your page, will see your main content first. Then the right and the left columns are placed.
In mobile device, web page has only one column. The same web page is used for regular browsers and a mobile device. It is very important because if you create two pages with the same content, Google will punish you for duplicate content.My tutorials are different from all other tutorials and books because I do not skip initial steps that a reader needed to start learning. Some times, you buy a book and start to read it. You understand everything from the point the author starts, but you do not know how to get to that starting point. I never miss the beginning!
Create MS Access database with credit_card table from. See my tutorial Data Model and Database project
create table credit_card(
cardid INT NOT NULL ,
name varchar(20),
type varchar(20),
expired date,
card_num INT,
credit float,
phone varchar(12),
address varchar(100),
city varchar(20),
state varchar(2),
zip varchar(10),
PRIMARY KEY(cardid)
);
Insert data in the table: copy and paste query in SQL View window.
Insert into credit_card (
cardid, name,type,expired,card_num,credit,phone,address,city,state,zip)
values
(1, 'CHASE','Visa','2006-01-01', 123456789, 20000.00 ,'123-123-1234',
'12 West 13th Street','New York','NY','12345-4321');
Insert into credit_card (
cardid, name,type,expired,card_num,credit,phone,address,city,state,zip)
values
(2, 'Bank One','MasterCard','2006-01-07', 987654321, 10000.00 ,'123-123-9876',
'16 West 17th Street','New York','NY','12345-4321');
Insert into credit_card (
cardid, name,type,expired,card_num,credit,phone,address,city,state,zip)
values
(1, 'Chase Platinum','MasterCard','2006-09-07', 999996789, 15000.00 ,'123-876-9876',
'19 West 19th Street','New York','NY','12999-4321');
See Data Model and Database project on this web site for details how to execute query in Access.
Create datasource name
Click Start, Settings, Control Panel...
In Windows 2000, XP, Vista ODBC located inside Administrative Tools folder. Double click ODBC Data Sources. ODBC Data Source Administrator window displays.
Select System DSN tab and click Add button. ODBC Microsoft Access Setup window displays. Type credit for data source name and click Select button. Select Database window displays. Find your database and click OK button. Click OK on Microsoft Access Setup window and OK on ODBC Data Source Administrator window.
PHP script:
<?php
$conn=odbc_connect("credit","" ,"");
print('<html>');
print('<head>')
print('<title>PHP and MS ACCESS</title>')
print('</head>');
print('<body>');
print('<table align="center" width="90%">');
print('<tr><th>CardID</th><th>CardName</th><th>Type</th>
<th>Expire</th><th>Number</th><th>Credit</th><th>Phone</th>
<th>Address</th><th>City</th><th>State</th><th>Zip</th></tr>');
if($conn)
{
$sql="select * from credit_card";
$row=odbc_exec($conn, $sql);
while(odbc_fetch_row($row))
{
$cardid=odbc_result($row,1);
$name=odbc_result($row,2);
$type=odbc_result($row,3);
$expired=odbc_result($row,4);
$card_num =odbc_result($row,5);
$credit =odbc_result($row,6);
$phone =odbc_result($row,7);
$address =odbc_result($row,8);
$city =odbc_result($row,9);
$state =odbc_result($row,10);
$zip =odbc_result($row,11);
print('<tr><td>'.$cardid.'</td><td>'. $name.'</td><td>'.$type.'</td>
<td>'.$expired.'</td><td>'.$card_num.'</td><td>'.$credit.'</td><td>'. $phone.'</td><td>'.$address.'</td><td>'.$city.'</td><td>'.$state.'</td>
<td>'.$zip.'</td></tr>');
}
print('</table>');
print('</body>');
print('</html>');
Good luck!
Did you find information useful? Send to your friend a link to this page
Please rate the tutorial
| Comments |
|---|
Web programming Tips