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 ++;