Php-PHP source code

Source: Internet
Author: User
This article mainly introduces how php connects to the access database and converts it to txt writing. it involves php connection, access database reading, and related operation skills for writing txt files, for more information about how to connect to the access database and write txt files in php, you can refer to the next article. This article describes how to connect to, read, and write txt files in php, for more information, see

This example describes how php can connect to the access database and convert it to txt. We will share this with you for your reference. The details are as follows:

The code here enables PHP to read the home location of the mobile phone and import the txt file (the mobile phone home location database is included at the end of the article)

Mdbtotxt. php code:

 Provider = 'Microsoft. jet. oledb.4.0 '; $ conn-> Open (ROOT. '\ callerloc. mdb '); // file address $ rs = new com ('adodb. recordset '); $ rs-> Open ('select * from '. TABLE, $ conn, 1, 1); // query TABLE $ I = 0; $ page = 1; if (! Empty ($ _ GET ['Page']) {$ page = $ _ GET ['Page']; if ($ page <1) $ page = 1; if ($ page> $ rs-> PageCount) $ page = $ rs-> PageCount;} $ rs-> AbsolutePage = $ page; // open the file $ fp = fopen (OUTPUTFILE, "w"); echo'
'; Foreach ($ rs-> Fields as $ name) {echo' '; Fwrite ($ fp, $ name-> Name. "\ t");} fwrite ($ fp, "\ r \ n"); echo' '; (;! $ Rs-> EOF; $ rs-> MoveNext () {echo' '; Foreach ($ rs-> Fields as $ name) {// echo' '; Fwrite ($ fp, $ name. "\ t") ;}$ I ++; fwrite ($ fp, "\ r \ n"); if ($ I % 1000 = 0) echo $ I.""; Echo' '; If ($ rs-> AbsolutePosition >=$ rs-> AbsolutePage * $ rs-> PageSize) break;} echo''; Fclose ($ fp);?>
'. $ Name-> Name .'
'. $ Name .'

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.