Home > Article > Backend Development > Well, with everyone's support, I have now successfully converted the access data to mysql form. I will dedicate it to those who need it_PHP tutorial
The first step is to prepare the database. To install the data source (this took me several days), first click on
odbc data source (32-bit)
in the control panel, click to enter and select
User DSN (actually the default)
, select the option
MS ACCESS 97 DATABASE, and click the configuration button to the right.
A window will appear with the name: [Odbc Microsoft Installation].
Select the database you want to call in the middle part. (Select the select button)
Then click the Advanced Options on the right side, and an [Advanced Settings Options] will pop up, in which you can set the user password and user name (note each name), in the option type below the column Click
defaultdir and enter your database (that is, the access database) in the bottom value. Then confirm one by one and return to the initial position (user DSN). At this time, start [adding] the data source you just added, select *.mdb (that is, access), and click Finish. Go to another page, in the beginning data source: data your database source name: (for example, I used to use taici.mdb, so now just enter taici in it). Then be sure to select the database you are looking for. Okay, now the database can come to an end.
The second step is the problem of program switching.
$cnx = odbc_connect('taici', 'Admin', 'WSD');
Remember? When I teach you to enter the user and password, I ask you to remember them, which are Admin and WSD. Do you know how to do it? !
$cur= odbc_exec( $cnx, 'select * from word' );
The word is one of the tables taici
$num_row=0;
$conn=mysql_pconnect("localhost" ,"wsd","wsd");//Connect to mysql
@mysql_select_db('sms',$conn) or
die("Unable to connect to the database, please contact the administrator!");// Open the mydb database of mysql
while( odbc_fetch_row( $cur )) //Fetch data one by one from the user table in the mydb library of sql server. If you select the data, you can add conditional judgment in the previous select statement
{
$num_row++;
$field1 = odbc_result($cur, 1); // The parameter i(1,2,3..) here refers to the i-th field in the record set, you You can select selectively, fieldi gets the value of the corresponding field, and then you can operate on fieldi
$field2 = odbc_result( $cur, 2 );
$field3 = odbc_result( $cur, 3 );
$field4 = odbc_result( $cur, 4 );