将MYSQL数据表从网站导出为CSV时出现错误的字符

我在这里找到了解决方案,但仍然遇到问题。
我的网站上有数据表,其中一个使用格鲁吉亚字体, 我的MYSQL数据库正常显示这些字体,但是当我尝试使用带有.csv文件的PC中的export.php下载此表时,字体就像</ p>


áƒ'áƒáƒ áƒáƒ¡áƒ•áƒšáƒ“ლშáƒ〜</ p>
</ blockquote>

在我的export.php中,代码如下:</ p>

 <  code> if(isset($ _ POST [“export”]))
{
header('Content-Transfer-Encoding:binary');

标题('Content-Type:text / csv; charset = UTF-8');

header('Content-Disposition:attachment; filename = data.csv');

$ output = fopen(“php:// output”,“w”);

fputcsv($ output,array('არდუინოსN','ნზანზაქცია','User ID','Transaction Date','Object Name','Terminal Name','Amount'));

$ query =“SELECT * FROM Table WHERE userID ='$ userID'ORDER BY trID DESC”;

$ result = mysqli_query($ db,$ query);

while($ row = mysqli_fetch_assoc($ result))
{
fputcsv($ output,$ row);

}
fclose($ output);

}
</ code> </ pre>

下载工作正常我得到了文件data.csv但是在这个文件里面的字符是无法识别的
图片链接 </ p>

有什么想法吗? 有什么问题?
如果您认为这是重复问题那么我可以告诉你没有因为在发布之前我发现了很多相同的解决方案但没有任何帮助
在我的数据库连接php文件中我添加了</ p>

< 预> <代码> $ DB-&GT; set_charset( “UTF8”);
</代码> </ PRE>

和</ p>

 <代码> mysqli_query  (“SET NAMES'utf8';”); 
</ code> </ pre>

但没有任何改变......任何会导致这个问题的提示都会很棒,谢谢你们提前 ...... </ p>
</ div>

展开原文

原文

I found solutions here but still got problems. I have data table in my website which one uses Georgian Fonts, in my MYSQL database those fonts are displayed normally but when I try to download this table using export.php in my PC with .csv file the fonts are like

გáƒáƒ¡áƒáƒ¡áƒ•áƒšáƒ”ლში

In my export.php the code is below:

if(isset($_POST["export"]))  
 {   
      header('Content-Transfer-Encoding: binary'); 
      header('Content-Type: text/csv; charset=UTF-8');  
      header('Content-Disposition: attachment; filename=data.csv');  
      $output = fopen("php://output", "w");  
      fputcsv($output, array('არდუინოს N','ტრანზაქცია', 'User ID', 'Transaction Date', 'Object Name', 'Terminal Name', 'Amount'));  
      $query = "SELECT * FROM Table WHERE userID='$userID' ORDER BY trID DESC"; 
      $result = mysqli_query($db, $query);  
      while($row = mysqli_fetch_assoc($result))  
      {  
           fputcsv($output, $row);  
      }  
      fclose($output);  
 }  

Download works fine I got file data.csv but inside this file characters are unrecognized Link for Image

Any ideas? What is wrong ? If you think that is duplicated Question then I can tell you NO because before posting here I found lots of same solutions but nothing helps In my database connection php file I have added

$db->set_charset("utf8");

and

mysqli_query("SET NAMES 'utf8';");

But nothing changed... Any tips what would cause this problem would be great, Thank you guys in advance...

dqc22586
dqc22586 看起来截图是Excel或其他电子表格应用程序。您确定该应用程序将CSV文件作为UTF-8编码文件读取吗?如果您使用UTF-8模式的文本编辑器打开CSV文件,您会看到什么(例如,如果您使用的是Windows,请使用Notepad++?)
大约一年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐