请问怎样实现写入php执行后的多条记录到txt文件,每次刷新就覆盖写入,谢谢 本帖最后由 ltinsky 于 2014-04-20 11:57:44 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 把 $fp = fopen("test.txt", "w");fclose($fp); 移到 while 循环外面$sql="select * from log " ; $query=mysql_query($sql);$fp = fopen("test.txt", "w");while($rs=mysql_fetch_array($query)) { switch($rs['status']) { case 1: $str =$rs['id']; fwrite($fp,$str); break; }}fclose($fp); 参考$fp = fopen("t.txt","w");for($i = 0; $i < 4; $i++){ fwrite($fp,$i);}fclose($fp); 为什么我的网站总是mysql错误 mysql left join 最后一条记录。 大神呐,为什么会这样? 如何实现根据不同的域名调用不同的head? 很大部分相似,但是也有很多不同细节的页面,重用吗? 页面加载顺序的问题~ 帮忙看下怎么会返回null http://www.sina.com/songlist.php?id=这种连接怎么实现啊 关于LIMIT的一些疑惑…… 为什么用JetBrains软件写程序在浏览器不能打开,老是出现Not Found phpstudy已经启动了 什么是第三代聊天室? 读写文本文件的分页显示问题
$fp = fopen("test.txt", "w");
fclose($fp);
移到 while 循环外面
$sql="select * from log " ;
$query=mysql_query($sql);
$fp = fopen("test.txt", "w");
while($rs=mysql_fetch_array($query)) {
switch($rs['status']) {
case 1:
$str =$rs['id'];
fwrite($fp,$str);
break;
}
}
fclose($fp);
for($i = 0; $i < 4; $i++){
fwrite($fp,$i);
}
fclose($fp);