How can I solve this problem by writing a php file?

Source: Internet
Author: User
Help write a php file to read the title field in the dede_article table of SQL _98uc database account root password 98uc and save the txt generated one by one row. every 20 titles are saved as a txt file. The txt files are arranged as 1, 2, 4, and 3. refresh php again. which of the following experts can help you write?
Read the title field in the dede_article table of the SQL _98uc database
Database account root password 98uc
The content in the called title is saved as one generated txt line by line. every 20 titles are saved as one txt, and the txt is arranged as 1, 2, 3, 4.
Refresh php again.
Which of the following experts can help you write?

------ Solution --------------------
Probably as follows, the wood has been tested, blind code
PHP code
Mysql_connect ("localhost", "root", "98uc") or die ("cocould not connect :". mysql_error (); mysql_select_db ("SQL _98uc"); $ result = mysql_query ("SELECT title FROM dede_article"); $ file_index = 1; $ I = 1; while ($ row = mysql_fetch_array ($ result, MYSQL_NUM )){! $ I % 20? $ File_index ++: $ I ++; file_put_contents ($ file_index. 'txt ', $ row [0], FILE_APPEND);} mysql_free_result ($ result );
------ Solution --------------------
! $ I % 20? $ File_index ++: $ I ++;

Change
If (! ($ I % 20) $ file_index ++;
$ I ++;

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.