Home > Backend Development > PHP Tutorial > 帮忙写个php,该如何解决

帮忙写个php,该如何解决

WBOY
Release: 2016-06-13 10:13:05
Original
879 people have browsed it

帮忙写个php
读取数据库sql_98uc表dede_article中的字段title
数据库帐号root密码98uc
调用到的title里的内容按一行一个生成txt保存起来.每20个title保存成一个txt,txt按照1,2,3,4这样排下去.
重新刷新php的时候就重新生成一次.
哪位高手可以帮忙写一下吗

------解决方案--------------------
大概如下,木有测试过,盲码

PHP code
 mysql_connect("localhost", "root", "98uc") or        die("Could 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);<br><font color="#e78608">------解决方案--------------------</font><br>!$i%20 ? $file_index++ : $i++;<br><br>改为<br>if(! ($i % 20) ) $file_index++;<br>$i++;<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
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