duanmu5039 2015-01-24 13:34
浏览 34
已采纳

如果单元格为空,则不会从数据库中获取电子邮件

I write a code to fetch emails of all users and then save them in a txt file but some users don't have and email because they registered using phone number so when i am trying to fetch
it dump in txt file like http://prntscr.com/5wf7cv

I want if cell is empty/NULL don't fetch anything Anyone can help me to Fix it?

    $sql=mysql_query("SELECT * FROM user  "); 
    while($row = mysql_fetch_array($sql)) {

 $email = $row['email']   ;

  $fp = fopen("emaillist.txt", "a");
$savestring = "
$email";
fwrite($fp, $savestring);
fclose($fp);
}
echo  "DONE ";
  • 写回答

3条回答 默认 最新

  • douliao5942 2015-01-24 13:36
    关注

    Change the query to

    SELECT * FROM user  WHERE email != NULL
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 simulink中怎么使用solve函数?
  • ¥30 dspbuilder中使用signalcompiler时报错Error during compilation: Fitter failed,求解决办法
  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题
  • ¥15 51单片机显示器问题