Home > Backend Development > PHP Tutorial > One of the ways to import Mysql from Access database_PHP tutorial

One of the ways to import Mysql from Access database_PHP tutorial

WBOY
Release: 2016-07-21 16:05:10
Original
865 people have browsed it

If you cannot import and export between different databases, it will be a terrible thing. Fortunately, in general, it can be achieved through different methods and approaches. There are many methods. I will provide one of them and provide one of my own. The processing idea is intended to inspire others,
Step 1: First, use the access database's own export function to customize a txt text document in a format that is easy to operate. This is also the key to the next step.
Step 2: First create a table with the same structure in mysql (of course, this step can be implemented programmatically in the third step. Due to the rush of time, I was unable to complete it, sorry)
Step 3: That is to say, you program it yourself and find a way to use the program to read each record of the exported file and write it into the Mysql data table.
$row = file("ipadress.txt"); //Read out the file Content into an array
$num=count($row);//The total number of records in the statistical table
mysql_connect("localhost","root","");//Connect to the database
mysql_select_db ("cht");
for ($i=0;$i<$num;$i++)//Start importing records
{
$fields=explode(",",$row[$ i]);
//echo $fields[0];
//echo $fields[1];
//echo $fields[2];
mysql_query("insert into ipaddress ( area_h,area_f,address) values('$fields[0]','$fields[1]','$fields[2]')");
     }
     echo "A total of $num was imported successfully! Import records, ";
I performed the above operations on an IP address comparison table downloaded from the Internet. If you are interested, you can give it a try.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/315737.htmlTechArticleIf different databases cannot be imported and exported, it will be a terrible thing. Fortunately, under normal circumstances It can be achieved through different methods and approaches. There are many methods. I...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template