mrchinaski Posted July 14, 2011 Report Share Posted July 14, 2011 Man ir datu baaze ar UTF-8 encodingu, tachu, kad eksporteeju kaa csv un atveru peec tam ekselii - nobruuk visi latvieshu burti, luuk skripts, ko izmantoju: <?php $host = 'localhost'; $user = 'xxxxxxxxx'; $pass = 'xxxxxxxxx'; $db = 'xxxxxxx'; $table = 'xxxxxx'; $file = 'export'; $link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error()); mysql_select_db($db) or die("Can not connect."); $result = mysql_query("SHOW COLUMNS FROM ".$table.""); $i = 0; if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)) { $csv_output .= $row['Field']."; "; $i++; } } $csv_output .= "\n"; $values = mysql_query("SELECT * FROM ".$table.""); while ($rowr = mysql_fetch_row($values)) { for ($j=0;$j<$i;$j++) { $csv_output .= $rowr[$j]."; "; } $csv_output .= "\n"; } $filename = $file."_".date("Y-m-d_H-i",time()); header("Content-type: application/vnd.ms-excel"); header("Content-disposition: csv" . date("Y-m-d") . ".csv"); header( "Content-disposition: filename=".$filename.".csv"); print $csv_output; exit; ?> Kaads varbuut var ieteikt, kaa to dariit taa, lai pareizi raadiitos lv simboli/burti. Paldies! Quote Link to comment Share on other sites More sharing options...
briedis Posted July 14, 2011 Report Share Posted July 14, 2011 (edited) Kur ir mysql_query("SET NAMES UTF8") ? Edited July 14, 2011 by briedis Quote Link to comment Share on other sites More sharing options...
mrchinaski Posted July 14, 2011 Author Report Share Posted July 14, 2011 (edited) Paldeis par aatro atbildi, tik es esmu galiigs iesaaceejs php... kur man iisti likt sho kveeriju? Meegjinaaju shaadi, bet joprojaam nekas: mysql_query("SET NAMES UTF8" , "$link"); $result = mysql_query("SHOW COLUMNS FROM ".$table.""); Paldies! Edited July 14, 2011 by mrchinaski Quote Link to comment Share on other sites More sharing options...
reiniger Posted July 15, 2011 Report Share Posted July 15, 2011 ... mysql_select_db($db) or die("Can not connect."); mysql_query("SET NAMES UTF8"); ... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.