Access database One of the ways to import MySQL _php Foundation

Source: Internet
Author: User
Tags access database
If you can not import the export between different databases, then it will be a terrible thing, fortunately, in general, through different methods and ways, can be achieved, there are a variety of methods, I provide one of them, to provide a way to deal with their own ideas, intended to introduce,
The first step: first of all, Access database using its own export capabilities, to customize a simple format for its operation of TXT text documents, which is related to the next step of the key.
The second step: first in MySQL to create a table of the same structure (of course, this step can be implemented in the third step, due to time, I failed to complete, sorry)
The third step: that is, you have programmed, to find a way to export the file with the program to read and write each record into the MySQL data table,
$row = File ("Ipadress.txt"); Read the contents of the file into an array
$num =count ($row);//Total number of records in the tables
mysql_connect ("localhost", "root", "");/Connection 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 "Import successful! A total of $num records imported, ";
The above operation I is for from the Internet under an IP address comparison of the operation, interested in can try,
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.